我有一个相对布局,它使用状态列表在按下、聚焦和禁用状态下显示不同的可绘制对象。现在按下状态,正常工作正常,但是当我做 a 时relativeLayoutObject.setEnabled(false)
,不显示正确的可绘制对象。我也有来自 XML 的relativeLayoutObject.setClickable(false)
设置android:state_enabled="false"
,但它们都不起作用。
这是我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:clickable="true"
android:layout_height="match_parent">
<!--SOME ITMES INSIDE THE LAYOUT-->
<RelativeLayout>
选择器是
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/drawable_d" android:state_enabled="false"/>
<item android:drawable="@drawable/drawable_n" android:state_focused="true"/>
<item android:drawable="@drawable/drawable_p" android:state_pressed="true"/>
<item android:drawable="@drawable/drawable_n"/>
</selector>
我将选择器应用为:relativeLayoutObject.setBackgroundDrawable(R.drawabled.button_state_list);