问题
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:
but when displayed in XHDPI it makes a very strange effect (look at the middle of the tab that is semitransparent:
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:
回答1:
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.
回答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.
回答3:
try this 9-patch image:
I hope this work.
Edit
try this 9-patch with padding from both sides:
来源:https://stackoverflow.com/questions/22158213/9-patch-image-incorrectly-streeched-in-xhdpi-density