如何更快地将Android的GradientDrawable升级为透明endColor

如何更快地将Android的GradientDrawable升级为透明endColor,android,android-layout,android-xml,Android,Android Layout,Android Xml,在以下代码示例中,渐变用于在矩形形状上生成阴影背景: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:angle="90" android:endColor="@android:color/transparent"

在以下代码示例中,渐变用于在矩形形状上生成阴影背景:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
            android:angle="90"
            android:endColor="@android:color/transparent"
            android:startColor="#8f000000"
    />
</shape>
此渐变从startColor到endColor的过程太慢。当通过渐变时为50%时为50%透明,当通过渐变时为75%时为75%透明

我希望这个梯度比50/50或75/75更快。例如,如果渐变的背景形状只有50%是透明的,那么渐变75%是透明的就更好了


Android的GradientDrawable XML类的哪个属性“加速”了梯度扩散?

我有一个小技巧。您可以尝试将此属性添加到现有代码中,并将其设置为与startColor或endColor相同的颜色,以使渐变快速进行

 android:centerColor="@android:color/transparent"

嘿,至少它有帮助: