0

I'm trying to create an app where the header fits the entire width of the screen. I've got a Samsung Galaxy S8 Plus with a density of XXXHDPI according to Google's Device Metrics yet when I create an assets folder inside the 'res' folder named 'drawable-xxxhdpi' it doesn't load accordingly and fit the screen. Why is this? I've also tried putting it in the XHDPI and XXHDPI incase it scaled up but no. There's always a white space where the image is not scaling up.

The drawables folder has been created correctly and the XXHDPI works fine for XXHDPI devices but doesn't for bigger screens.

The white space on the right when testing on a bigger device

enter image description here

Navneet Krishna
  • 5,009
  • 5
  • 25
  • 44

1 Answers1

0

drawable and assets are independent directories . To load Drawable from asets you need to use Drawable.createFromStream().

Drawable d = Drawable.createFromStream(getAssets().open("images/sky.png"), null);

Other than that just make the hierarchy right and use it in conventional way. asset should be parallel to res not inside res. Asset should be used to additional pre-bundled files not for images. because if you do this you can not provide multiple screen support.
So create Assets inside app/src/main/assets/. And drawable inside res.

You might wanna check out these links Where should put Assets and Where should put Drawables.

ADM
  • 20,406
  • 11
  • 52
  • 83