我在选择器中遇到state_selected问题。
<item
android:state_selected="true"
android:drawable="@drawable/red"
></item>
<item
android:state_pressed="true"
android:drawable="@drawable/blue"
></item>
<item
android:drawable="@drawable/white"></item>
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/list_item"
android:textAppearance="?android:textAppearanceLarge"
android:gravity="center"
android:text = "Hello"
android:background="@drawable/my_selector"
/>
</LinearLayout>
state_pressed工作正常(setEnabled方法有一个“true”值)。 有什么建议吗?
答案 0 :(得分:0)
要从选择器(while ( i <= 100) {
number = i + 1 + "<br />";
i = i + 1; // Increment counter
outputAreaRef.innerHTML = outputAreaRef.innerHTML + number;
}
)获得@drawable/red
背景,您应该选择android:state_selected="true"
:
TextView
为了更好地了解每个观点的状态,请检查
https://developer.android.com/reference/android/graphics/drawable/StateListDrawable.html#attr_android:state_selected