selector
以显示默认状态和按下状态。每个州都有自己的映像,如下面的代码所示。
change the hue of an image
并返回一个新的StateListDrawable以在ImageButton中使用。
我的问题
:如何实际将StateListDrawable应用于ImageButton的
android:background
以下是小部件布局的XML源:
<LinearLayout
android:id="@+id/LinearLayout01"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<ImageButton
android:id="@+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:background="@drawable/buttonselector" />
</LinearLayout>
与其使用硬编码的“@drawable/buttonselector”,不如使用我正在生成的动态选择器。