Forum Xamarin.Forms

android visual studio cannot compile resource not found

PB21PB21 ESMember

I am a rookie to Android. Ive created an interface in the main.axml file when I go to designer everything looks ok as far as layout goes.

in the res folder I have a file called MyColour.xml that has a number of colors set up.
the design view reflects those colors.

however when I compile it has loads of :
Severity Code Description Project File Line Suppression State
Error No resource found that matches the given name (at 'background' with value '@p1:color/white'). NewXamarin C:\Users\peter\documents\visual studio 2015\Projects\NewXamarin\NewXamarin\Resources\layout\Main.axml 2

Not sure how to correct this as I would like to move over to a coding stage and get the spinners populated but this is hindering me. assistance would be appreciated I am in latest version of visual studio 2015

the main code is
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:p1="http://schemas.android.com/apk/res/android" p1:orientation="vertical" p1:minWidth="25px" p1:minHeight="25px" p1:layout_width="match_parent" p1:layout_height="match_parent"> <LinearLayout p1:orientation="horizontal" p1:minWidth="25px" p1:minHeight="25px" p1:layout_width="wrap_content" p1:layout_height="35" p1:id="@+id/linearLayout1" p1:layout_margin="50"> <Spinner p1:layout_width="190.0dp" p1:layout_height="35" p1:id="@+id/spinner1" p1:layout_marginRight="75" /> <Spinner p1:layout_width="187.0dp" p1:layout_height="match_parent" p1:layout_marginRight="73.0dp" p1:id="@+id/spinner2" /> </LinearLayout> <LinearLayout p1:orientation="horizontal" p1:minWidth="25px" p1:minHeight="25px" p1:layout_width="wrap_content" p1:layout_height="wrap_content" p1:id="@+id/linearLayout2" p1:layout_margin="50"> <Spinner p1:layout_width="190.0dp" p1:id="@+id/spinner3" p1:layout_height="35" p1:layout_marginRight="75" /> <Spinner p1:layout_width="190.0dp" p1:layout_height="75" p1:layout_marginRight="73.0dp" p1:id="@+id/spinner4" /> </LinearLayout> <LinearLayout p1:orientation="horizontal" p1:minWidth="25px" p1:minHeight="25px" p1:layout_width="wrap_content" p1:layout_height="wrap_content" p1:id="@+id/linearLayout3" p1:layout_marginRight="0.0dp" p1:layout_margin="50"> <Spinner p1:layout_width="190.0dp" p1:layout_height="35" p1:id="@+id/spinner5" p1:layout_marginRight="75" /> <Spinner p1:layout_width="190.0dp" p1:layout_height="75" p1:layout_marginRight="73.0dp" p1:id="@+id/spinner6" /> </LinearLayout> <LinearLayout p1:orientation="vertical" p1:minWidth="25px" p1:minHeight="25px" p1:layout_width="match_parent" p1:layout_height="match_parent" p1:id="@+id/linearLayout4"> <GridLayout p1:layout_width="wrap_content" p1:layout_height="wrap_content" p1:layout_gravity="center" p1:columnCount="5" p1:orientation="horizontal"> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p21button" p1:text="P21" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p22button" p1:text="P22" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p23button" p1:text="P23" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p24button" p1:text="P24" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p25button" p1:text="P25" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p16button" p1:text="P16" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p17button" p1:text="P17" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p18button" p1:text="P18" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p19button" p1:text="P19" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p20button" p1:text="P20" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p11button" p1:text="P11" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p12button" p1:text="P12" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p13button" p1:text="P13" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p14button" p1:text="P14" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p15button" p1:text="P15" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p6button" p1:text="P6" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p7button" p1:text="P7" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p8button" p1:text="P8" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p9button" p1:text="P9" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p10button" p1:text="P10" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p1button" p1:text="P1" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p2button" p1:text="P2" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p3button" p1:text="P3" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p4button" p1:text="P4" /> <Button p1:layout_margin="5dp" p1:layout_centerInParent="true" p1:background="@p1:color/white" p1:textColor="@p1:color/black" p1:id="@+id/p5button" p1:text="P5" /> </GridLayout> </LinearLayout> </LinearLayout>

The color xml:
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="red">#ff0000</color> <color name="green">#00ff00</color> <color name="blue">#0000ff</color> <color name="white">#ffffff</color> <color name="black">#000000</color> </resources>

Answers

  • YayinoYayino ZAMember ✭✭

    the answer is on (at 'background' with value '@p1:color/white').

    which resource is the color/white

    assuming you color xml file is in the drawable folder

    the call for resource should be

    @p1:drawable/color

    how ever i dont thing you need to go to the troubel you can simply specify the color inline

    like so

    p1:background="#ffffff" if you doing solid colors

    your approch better if you using gradiants or shades

    exmaple

    <?xml version="1.0" encoding="UTF-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_pressed="true" >
            <shape>
                <solid
                    android:color="#926803" />
                <stroke
                    android:width="1dp"
                    android:color="#222222" />
                <corners
                    android:radius="0dp" />
                <padding
                    android:left="15dp"
                    android:top="15dp"
                    android:right="15dp"
                    android:bottom="15dp" />
            </shape>
        </item>
        <item>
            <shape>
                <gradient
                    android:startColor="#fcefa8"
                    android:endColor="#fdfbf1"
                    android:angle="270" />
                <stroke
                    android:width="1dp"
                    android:color="#d6bd18" />
                <corners
                    android:radius="0dp" />
                <padding
                    android:left="15dp"
                    android:top="15dp"
                    android:right="15dp"
                    android:bottom="15dp" />
            </shape>
        </item>
    </selector>
    

    this is a button background i used a while a go

    you call it like so

  • PB21PB21 ESMember

    aha ok i see it now ok thank you so much haileab

Sign In or Register to comment.