Why does Visual Studio force me to place drawables in the root drawable folder?

fljohwatfljohwat USMember
edited October 2012 in Xamarin.Android

I have various resolutions of my icon in the mddp, ldpi, hdpi etc, but non in the root drawable folder.
This is allowed when doing native java development, the fallback is mdpi.
However, if I dont put a copy in the root folder, VS gives a compiler warning saying it cant find the resource.

Posts

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    What's the compiler warning?

    Can you provide the diagnostic MSBuild output?

  • fljohwatfljohwat USMember

    No resource found that matches the given name (at 'icon' with value '@drawable/ic_launcher').

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    Are you sure you're setting the Build action to AndroidResource?

    What files are in $(IntermediateOutputPath)\res (e.g. obj\Debug\res)? Is there a ic_launcher.* file within that directory?

  • fljohwatfljohwat USMember

    It's not the build action. That action is correct. The file exists in each of the resolution specific subdirectories. If I dont ALSO copy it to /Drawable, I get this error. If I copy the file from say /Drawable/mdpi to Drawable, no error.

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    Wait, /Drawable/mdpi? Are you sure you don't mean Drawable-mdpi? If you are nesting directories, try moving your nested directories to be sibling directories and s#/#-#g (turning Drawable\mdpi into Drawable-mdpi) as specified in the Providing Alternative Resources Google Documentation.

  • fljohwatfljohwat USMember

    Yes, sorry, typo, see image.

  • JonathanPryorJonathanPryor USXamarin Team Xamurai

    That's...not right. Read the Providing Alternative Resources Google Documentation section carefully:

    1. Create a new directory in [Resources] named in the form <resources_name>-<config_qualifier>.

    ...

    For example, here are some default and alternative resources:

    res/
        drawable/   
            icon.png
            background.png    
        drawable-hdpi/  
            icon.png
            background.png  
    

    Note that e.g. drawable-hdpi isn't nested within a drawable directory, it's a sibling to the directory. Compare to your screenshot:

    Resources\
        Drawable\
            drawable-hdpi\
            drawable-ldpi\
            drawable-mdpi\
                ic_icon_search.png
                ic_launcher.png    
            drawable-xhdpi\
            button.xml
            ic_launcher.png    
            person.png
            standard_normal.xml
            standard_pressed.xml
            standardselector.xml
    

    See the difference?

  • fljohwatfljohwat USMember

    Aah....I see. Thanks for pointing it out.

  • Aruna.1809Aruna.1809 USMember

    how to add png files to resource file

Sign In or Register to comment.