是否有可能抖动渐变绘制? [英] Is it possible to dither a gradient drawable?

查看:188
本文介绍了是否有可能抖动渐变绘制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的绘制:

<?xml version="1.0" encoding="utf-8"?>
<shape 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    >

    <gradient 
        android:startColor="@color/content_background_gradient_start"
        android:endColor="@color/content_background_gradient_end" 
        android:angle="270"
        />

</shape>

的问题是,我得到严重束带上HDPI设备(如Nexus的一个和德罗伊德)由于梯度随着从屏幕的顶部到最底部

The problem is that I get severe banding on hdpi devices (like the Nexus One and Droid) since the gradient goes from the top of the screen to the very bottom.

据<一href="http://idunnolol.com/android/drawables.html#shape_gradient">http://idunnolol.com/android/drawables.html#shape_gradient没有一个抖动属性的梯度。有什么我可以做平稳的梯度?

According to http://idunnolol.com/android/drawables.html#shape_gradient there isn't a "dither" attribute for a gradient. Is there anything I can do to smooth the gradient?

注:加入抖动=true将形状似乎并没有正常工作

Note: adding dither="true" to shape doesn't seem to work.

推荐答案

我写你所引用的文件。我已经采取再看看code,不幸的是有没有办法使通过显式调用抖动对GradientDrawable除了 GradientDrawable.setDither()在code

I wrote the documentation you referenced. I've taken another look at the code and unfortunately there's no way to enable dithering on a GradientDrawable except by explicitly calling GradientDrawable.setDither() in code.

(的方式,codeS看起来,技术上的,你可以包括梯度作为的只有的的孩子&LT;选择&GT; ,并启用抖动对整个选择;但是,这绝对是一个黑客)

(The way the codes looks, technically you could include the Gradient as the only child of a <selector>, and enable dithering on the entire selector; however, it's definitely a hack.)

我不相信使抖动会真正解决您的问题,因为抖动(至少它指出,在Android官方文档)是解决条纹问题时,该设备具有过小的调色板。这似乎是一个条带的问题,由于倾斜的大小。

I'm not convinced enabling dithering will actually solve your problem, as dithering (at least as it's noted in the official Android docs) are for solving banding problems when the device has too small of a color palette. This seems to be a banding problem due to the size of the gradient.

这篇关于是否有可能抖动渐变绘制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆