1

给定一个像这样的drawable:

  <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>

我想创建一个动画师来为纯色制作动画,但我似乎找不到访问图层列表中属性的方法。

4

1 回答 1

2

我想出了如何做到这一点:

ImageView iv = (ImageView) findViewById(<id of the layer-list drawable>);
LayerDrawable layer = (LayerDrawable) iv.getDrawable();
GradientDrawable border = (GradientDrawable) layer.getDrawable(0);
于 2016-01-04T15:40:46.447 回答