0

I've been reading about the drawable-XXdpi folders, and I created my icons in all sizes.

What I want to do now, is to put a background image on my main screen. And what my assumption is at this moment, is that I don't work with DP at this moment but with PX, because my background image needs to fill all the pixels.

When this assumption is correct, where do I put my created background images?

I've created one for 480*320, 800*400 to the largest 1600x2560. In my assumption I can't put them in the drawable-XXdpi folders because those are DPI related, and I need to fill all the pixels.

4
  • I would put it in the drawable folder (non- dpi related), but not sure if its the best practice
    – Blaze Tama
    Commented Dec 2, 2014 at 8:34
  • @Der Golem: shouldn't I create a background with the exact pixel size instead of using a stretched image?
    – Michel
    Commented Dec 2, 2014 at 13:20
  • @Der Golem: Thanks! Can you make your comments an answer? Your comments made clear that I should not use px.
    – Michel
    Commented Dec 4, 2014 at 9:20
  • Ok, done. Hopefully it will help others, too. Commented Dec 4, 2014 at 9:36

4 Answers 4

2

You can put your drawable that is not specific for each dpi into drawable-nodpi folder. But basically, as Der Golem describes, you should always use dp.

1

I don't work with DP at this moment but with PX ... You should always use DP.
To fill all the available space, just use android:background instead of android:src.

Note that the image will be stretched (if you don't make it a 9 patch - this will also be stretched, but in a "controlled manner").


To create a background with the exact pixel size is not a good practice.
You'd end up wit oversized images.

Better practices include (not mutually exclusive - they can be stacked by using a Layer-List):

  • stretchables (such as 9 patches)
  • tiles (seamlessly tileable pictures)
  • drawables (which are vectorial, like SVG files)
    These ones include:
    a - shapes
    b - gradients
    c - ...
  • SVG (through 3rd party libraries)
  • ...

Also consider that "the exact pixel size" might be different from what you expect.
You have to take in account the StatusBar, the ActionBar/ToolBar, the MenuBar, ...

1

There is no separate folder architecture for putting px files. You need to use drawable-hdpi , drawable-mdpi, drawable-xhdpi, drawable-xxhdpi.

1

The approximate pixel values for different dps are like this:

ldpi    = 600.00px x 360.00px
mdpi    = 800.00px x 480.00px
hdpi    = 1200.00px x 720.00px
xhdpi   = 1600.00px x 960.00px
xxhdpi  = 2400.00px x 1440.00px

Check these links for more details:

http://pixplicity.com/dp-px-converter/

http://developer.android.com/guide/practices/screens_support.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.