Where is the drawable folder?

RonNYCRonNYC ✭✭✭Member ✭✭✭

I want to replace the Activity label "MyApp" with an image. I assume I need to use a folder called drawable, but so far that hasn't worked.

I created a drawable folder in my Resources folder and put my jpg in there.

And made these changes to the axml:

android:minHeight="?attr/actionBarSize"
android:background="@drawable/banner.jpg"

When I build the app I get this error:

No resource found that matches the given name (at 'background' with value '@drawable/banner.jpg').

Answers

  • GuyProvostGuyProvost ✭✭✭ CAMember ✭✭✭

    You sure that you created this in a xamarin.android project ? And not a forms project ?

    The drawable should be in the resources folder of the xamarin.Android Project.

    If it's there, make sure that the resource.designer.cs file exists and is included in the project. This file should be found in the resources folder. If it's not there, this aint a Xamarin.Android project!

  • RonNYCRonNYC ✭✭✭ Member ✭✭✭

    Both are there. Not a forms project.

  • RonNYCRonNYC ✭✭✭ Member ✭✭✭

    In the Resources folder I have several mipmap-xxxx folders like mipmap-mdpi, etc. , a values folder, layout, and Menu.

  • RonNYCRonNYC ✭✭✭ Member ✭✭✭

    There are drawable folders off the obj folder.

    All I want is to know how to use my own png file for the app's icon on Android.

  • GuyProvostGuyProvost ✭✭✭ CAMember ✭✭✭

    The resources folder shoud be in "[projectFolder]/Resources/drawable ". If it's not there (wonder why) you can create it, add the png in it and add the png file to the project. You can't just drop a file in the resources folder and hope Android to find it, you have to add the file to the project. Then Visual Studio will regenerate the "resource.designer.cs" file in which a reference to your png will be!

    You'll then be able to refer to the png with "@drawable/banner", no extension.

    By the way in your example, you seems to be using a jpg and not a png, but in the last post you talked about a png.

  • YorkGoYorkGo Xamurai CNMember, Xamarin Team Xamurai

    android:background="@drawable/banner.jpg"

    No resource found that matches the given name (at 'background' with value '@drawable/banner.jpg').

    Solution 1:

    Place your .jpg file in mipmap folder, then, modify your android:background like below:

    android:background="@mipmap/banner"
    

    Solution 2:

    Create related drawable folder and place your image in the drawable folder.

    For more detailed information about drawable folder you could refer to: Alternate Resources

  • RonNYCRonNYC ✭✭✭ Member ✭✭✭

    Why VS doesn't create drawable folders for me, I don't know. As a test I create a Single Page app.

    I did put my jpg file into a mipmap folder and modified the axml but I get:

    No resource found that matches the given name (at 'background' with value '@mipmap/alkemi').

    I mean, adding a graphic banner to the app should not be a multi-day process.

  • YorkGoYorkGo Xamurai CNMember, Xamarin Team Xamurai

    No resource found that matches the given name (at 'background' with value '@mipmap/alkemi').

    Please make sure your image build action is Android Resource.

  • gopal2222gopal2222 Member

    Hy brother. I got the same problem. what is the solution?

Sign In or Register to comment.