0

如何在 Android 上使用渐变填充形状?例如,LinearGradient、RadialGradient 或 SweepGradient。

4

1 回答 1

-1

您可以从 xml 中执行此操作。在drawables文件夹中创建一个xml文件,文件应该是这样的

<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- fill stroke color  -->
<stroke
    android:width="1dip"
    android:color="#bd5426" />
<!-- gradient color   -->
<gradient
    android:angle="-270"
    android:endColor="#B4BBBD"
    android:centerColor="#color you want"
    android:startColor="#D9DFE0" />

 
</shape>

最后你在你的视图中使用

android:background="@color/name_of_xml_defined_above"
于 2012-11-18T08:49:58.537 回答