Question

I asked this question in chat rooms tagged with Android but it turns out they didn't encounter this before, and I cannot find specific question either on Google so I think this is a valid point to post this as a question here.

The problem is, if I refer to an XML file format as android:background="@drawable/bg", I got compilation error saying:

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

But if I put some file like for e.g ".png" or ".jpg", it compiles well. Sounds like it does not recognize the file as a valid drawable? Either if I put that file in other location, its just don't compile.

This is the bg.xml contains:

<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
     android:shape="rectangle">
  <corners android:radius="2dp" />
  <stroke
      android:width="1dp"
      android:color="#fff" />
</shape>

What am I doing wrong?

Edit:

I've create the "res" and "drawable" folders by myself because it's not default in this kind of environment.

Was it helpful?

Solution

Set the Build Action property of item bg.xml to DrawableResource.

OTHER TIPS

I am also facing this problem in VS 2013. Then i do this.. In the solution explorer click on drawable folder and check if your image exists here or not. If not then right click on drawable folder and click add-> existing item and then add your Image here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top