Android 在可绘制层列表中设置项目动画
给出了一个类似于这样的可拉伸模型:Android 在可绘制层列表中设置项目动画,android,android-activity,android-animation,drawable,layer-list,Android,Android Activity,Android Animation,Drawable,Layer List,给出了一个类似于这样的可拉伸模型: <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle"> <solid android:color="#FF0000"/> </shape> </it
<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);
ImageView iv=(ImageView)findViewById();
LayerDrawable layer=(LayerDrawable)iv.getDrawable();
GradientDrawable边框=(GradientDrawable)layer.getDrawable(0);