Tôi đang cố thay đổi kiểu TextView dựa trên trạng thái của nó. styles.xml My chứa:Thay đổi kiểu TextView state_pressed/state_focused/state_selected
<style name="text_normal_ops">
<item name="android:gravity">left</item>
<item name="android:textColor">@color/text_usual_color</item>
<item name="android:textStyle">bold</item>
</style>
<style name="text_normal_ops_pressed">
<item name="android:gravity">left</item>
<item name="android:textColor">@color/text_pressed</item>
<item name="android:textStyle">bold</item>
</style>
chọn của tôi (text_ops.xml
) được định nghĩa là:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" style="@style/text_normal_ops_pressed" />
<item android:state_focused="true" style="@style/text_normal_ops_pressed" />
<item android:state_selected="true" style="@style/text_normal_ops_pressed" />
<item style="@style/text_normal_ops"/>
</selector>
Nhưng khi tôi áp dụng điều này để TextView của tôi (style="@drawable/text_ops"
) nó không hoạt động. Bất kỳ mẹo nào?
Cảm ơn
đã bạn giữ styles.xml ur trong res-> thư mục giá trị ??? – Hanry
Có, tôi có hanry. – trenpixster