Question

I have problems with a 9 patch image when displayed in XHDPI.

It seems as there were a bug in Android because when displayed in HDPI is displayed correctly:

hdpi image

but when displayed in XHDPI it makes a very strange effect (look at the middle of the tab that is semitransparent: enter image description here

It's very strange and I can't see why it'sworking this way when in XHDPI. Basically de 9 patch is a one line gradient with some transparent margin needed for the viewpager indicator:

nine patch image

Was it helpful?

Solution 2

Yoah put me in the right direction. My problem was that testing phone (Nexus 5) is not a XHDPI device, it's a XXHDPI device. And as scaling is needed to convert from XHDPI to XXHDPI what explains Yoah applies to my case also.

OTHER TIPS

I assume your image is saved under the hdpi folder and there is no image in the xhdpi folder. You can copy the image file to the xhdpi folder, or change the image to the following. When the screen is xhdpi, and the image is hdpi, before opening in it is scaled to be 50% larger, so sub-pixel stretching will do the effect you see.

Image that prevents sub-pixel stretch errors

try this 9-patch image:

enter image description here

I hope this work.

Edit

try this 9-patch with padding from both sides:

enter image description here

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