Android view dithering

天大地大妈咪最大 提交于 2020-01-13 05:15:53

问题


As you can see from the screenshot below, the "titlebar" is getting these ugly banding lines across the areas with text that extend the entire width of the screen. It's even more noticeable on a real device.

Is there any way to work around this?


回答1:


From Android Developers: Widget Design Guidelines:

In some cases, devices have low pixel depths that can cause visual banding and dithering issues. To solve this, application developers should pass assets through a "proxy" drawable defined as XML:. This technique references the original artwork, in this case "background.9.png", and instructs the device to dither it as needed.

EDIT: Example source. This is an xml file in your res/drawables directory:

<?xml version="1.0" encoding="UTF-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/title_bar_medium"
    android:dither="true" />



回答2:


Add android:tileMode="repeat" in this code, like this -

<?xml version="1.0" encoding="UTF-8"?>
<bitmap
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/b1"
    android:tileMode="repeat"
    android:dither="true" />

Reason is, on some devices it still stretches the image and it looks pretty bad, check this Reference here



来源:https://stackoverflow.com/questions/2210976/android-view-dithering

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