我有一个ImageView, 和一个<layer-list>in /res/drawable/。这是层列表:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<!-- This is a 24dp x 24dp PNG -->
<bitmap android:src="@drawable/ic_secondary_arrow"
android:gravity="center"/>
</item>
<item>
<shape android:shape="oval">
<stroke android:color="@color/icon_primary_background"
android:width="2dp"/>
<solid android:color="@android:color/transparent" />
</shape>
</item>
</layer-list>
ImageView 没有什么特别的:
<ImageView
android:id="@+id/arrow"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_margin="16dp"/>
当使用src或setImageDrawable(int)指向图层列表时,center似乎被忽略了(或者至少这不是我想要的行为):

我想显示如下。这可以使用background(或setBackground(Drawable)) 代替src:

我坚持的原因是因为setBackground(Drawable)仅限于 API16+,我宁愿不因此限制我的观众。
那么,我错过了什么?
编辑:正如@pskink 在下面指出的那样,我错过了setBackgroudDrawable(Drawable). 但是,这仍然是一个偶然的问题。我真的很想知道在这种情况下src和background(以及各自的方法)的不同行为背后的原因是什么。