给定一个类似这样的可绘制对象:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#FF0000"/>
</shape>
</item>
<item>
<nine-patch android:src="@drawable/button_down_red" />
</item>
</layer-list>
我想创建一个动画师来为纯色设置动画,但我似乎找不到访问图层列表中的特性的方法。
我想好了如何做到这一点:
ImageView iv = (ImageView) findViewById(<id of the layer-list drawable>);
LayerDrawable layer = (LayerDrawable) iv.getDrawable();
GradientDrawable border = (GradientDrawable) layer.getDrawable(0);