我有以下绘制XML:如何更改内部选择器内部渐变的颜色?
background_view_rounded_top.xml
<?xml version="1.0" encoding="UTF-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetBottom="0.0px"
android:insetLeft="1.0px"
android:insetRight="1.0px"
android:insetTop="1.0px" >
<selector>
<item android:state_pressed="true">
<shape>
<gradient
android:angle="270.0"
android:endColor="@color/base_end_color_pressed"
android:startColor="@color/base_start_color_pressed" />
<corners
android:bottomLeftRadius="0.0dip"
android:bottomRightRadius="0.0dip"
android:radius="2.0dip"
android:topLeftRadius="10.0dip"
android:topRightRadius="10.0dip" />
</shape>
</item>
<item>
<shape>
<gradient
android:angle="270.0"
android:endColor="@color/base_end_color_default"
android:startColor="@color/base_start_color_default" />
<corners
android:bottomLeftRadius="0.0dip"
android:bottomRightRadius="0.0dip"
android:radius="2.0dip"
android:topLeftRadius="11.0dip"
android:topRightRadius="11.0dip" />
</shape>
</item>
</selector>
</inset>
我想改变其startColor
和endColor
。我不能通过简单地复制这个xml来做到这一点,因为我会多次使用这个drawable,并且有几十个这样的xml不是一个选项。所以我想重复使用这个xml并在代码中改变这些颜色。
我也有background_view_rounded_round_bottom /中/单和也没有圆角的版本,所有这些xmls也应该有参数化的颜色。
只需用此替换您的xml。你还需要什么。 –
你不明白我的问题。你仍然需要几十个xmls来改变颜色。 – SuitUp
您需要更改哪种颜色以及用于何种目的。我无法得到你所说的。 –