-1

Ok this is very stupid but i can't find a way out. As a brief test I put bg.png into drawable/drawable-xhdpi but when i reference it

<LinearLayout

 xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical"
 android:id="@+id/details_parent"
 android:background="@drawable/bg">
...
</LinearLayout>

I get this error Couldn't resolve resource @drawable/bg

I tried copying it in every drawable-somethingDPI folder, because that's what I will do when I'll have the different size of it, but still nothing.

Finally, if I simply move it to the parent folder /drawable everything works.

But this is nonsense! I want to put the different sized pictures in their respective -DPI folder to support the various dpi buckets.

What am I missing?

MaX
  • 489
  • 7
  • 18
  • To the down voter: you know that not all questions must be smart? I searched for my problem thoroughly before asking, and as a matter of fact i was missing something not related at all with the actual problem. But whatever makes your day mate. Cheers – MaX Apr 12 '17 at 09:27

2 Answers2

0

that's is a very sense one as you give it path

@drawable/bg

and the real path is

drawable/drawable-xhdpi/bg

when you create the different drawable folders create it in the res package not inside the drawable itself

Sattar
  • 2,453
  • 2
  • 33
  • 47
  • Ha! thank you! I missed that those folders needed to be created in res and not in drawable itself! I'll accept the answer as soon as the system allows me to – MaX Apr 12 '17 at 09:17
0

Max, Android Studio takes images or resources according to resolution from drawable-somethingDPI folder. But if your Mobile or device have different resolution or don't support that resolution then It won't load and will give you error.

Note: if you put your Images inside drawable folder than drawable is supported by all screen resolution. So this is the reason behind that when you put images inside drawable it works.

yogi
  • 293
  • 1
  • 7