【发布时间】:2019-01-10 09:46:39
【问题描述】:
我目前正在尝试使用当前纯白色的 Drawable 对一些 ImageButton 进行着色。 Tint Color 应该由 StateList 提供,并且应该根据按钮的当前状态而改变。状态列表看起来像:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#FF0000"/>
<item android:color="#00FF00" android:state_enabled="false"/>
<item android:color="#0000FF" android:state_pressed="true" android:state_enabled="true"/>
</selector>
按钮的布局 XML sn-p 是:
<ImageButton
android:id="@+id/btnNext"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/vertical_content_padding"
android:layout_marginEnd="@dimen/horizontal_content_padding"
android:contentDescription="@string/next"
android:src="@drawable/ic_chevron_right_white_24dp"
android:tint="@color/state_btn_tint_light"/>
颜色状态列表中的默认色调已选择并正确显示。但是禁用按钮或按下它不会触发图标的任何颜色变化。我也尝试使用setImageTintList 进行务实的设置。
【问题讨论】:
标签: android