0

I am Trying to set to set this picture soccer_field in drawable folder. When I view the "graphical layout" it is showing the background, but when I run it on my device it is not ..

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/soccer_field"
android:orientation="horizontal">
</LinearLayout>

Why is this happening and how to solve it ??

K.Habib
  • 15
  • 2

1 Answers1

1

The only difference might be different screen resolutions between Emulator and your device. So maybe your device is looking in another drawable folder like drawable-xhdpi and it cannot find the drawable in their or in any other drawable folder suitable for the device resolution.

Here you can find more about this

jboi
  • 11,324
  • 4
  • 36
  • 43
  • I tried to put my picture in all the drawable folders and it still not working !! – K.Habib Oct 08 '13 at 16:11
  • If it can't find it in the `drawable-??dpi` folder, it looks in `drawable` by default, which is where the OP says it is. – Geobits Oct 08 '13 at 16:13
  • Well, difficult. The `soccer_field` is a PNG file? Do you do something with the layout in your code? Can you try and add some text view with dummy text to see, if anything is shown on your device? – jboi Oct 08 '13 at 16:17
  • @Geobits I think so too. My guess was, that in the other folder another drawable with the same name was put (accidentally) – jboi Oct 08 '13 at 16:19
  • I tried to change the picture and it worked .. would it be because the picture i was trying previously had a size of 1.5 MB "the new one is just 51 KB" ?? .. – K.Habib Oct 08 '13 at 16:21
  • Good to see that it works now. At least the bitmap should take a while to be shown and depending on your device might be too much for the memory. – jboi Oct 08 '13 at 16:35