9 patch image incorrectly streeched in xhdpi density

社会主义新天地 提交于 2019-12-19 10:16:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!