drawableLeft,button等属性图片设置大小
你是否也遇到了,在使用RadioButton的button属性,TextView的drawableLeft属性的图片需要设置大小,又不想找ued切多张图
- 有状态的图片资源
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true">
<layer-list>
<item android:width="@dimen/dimen_px_40" android:height="@dimen/dimen_px_40" android:drawable="@drawable/check_checked" />
</layer-list>
</item>
<item android:state_checked="false">
<layer-list>
<item android:width="@dimen/dimen_px_40" android:height="@dimen/dimen_px_40" android:drawable="@drawable/check_normal" />
</layer-list>
</item>
</selector>
- 无状态的图片资源*
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:width="@dimen/dimen_px_40"
android:height="@dimen/dimen_px_40"
android:drawable="@drawable/check_checked" />
</layer-list>
- layer-list的原本用法
layer-list是用来创建包含多个图层的重叠Drawable,类似布局FrameLayout,对应的java类是LayerDrawable
可以通过item 的 left,top,right,bottom设置图层偏移,有很多使用示例
https://blog.csdn.net/android_cmos/article/details/80033784