StateListDrawable
顾名思义,状态列表drawable
通常xml中定义的selector标签的drawable最终会实例化成这种drawable
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/default_unfocused_background" />
<item android:drawable="@drawable/default_focused_background" android:state_focused="true" />
<item android:drawable="@drawable/default_unfocused_background" android:state_focused="false" />
</selector>
Java代码方式
StateListDrawable drawable = new StateListDrawable();
//这里有多种状态
drawable.addState(new int[]{
android.R.attr.state_selected}, drawable);
drawable.addState(new int[]{
android.R.attr.state_focused}, resource);
drawable.addState(new int[