Có cách nào để áp dụng kiểu cho nút khi nhấn nút không?Áp dụng kiểu khác nhau cho nút khi nhấn
Nếu tôi có một phong cách style.xml:
<resources>
<style name="test">
<item name="android:textStyle">bold</item>
</style>
</resources>
một selector trong button.xml:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/test_pressed"
style="@style/test"
android:state_pressed="true"/>
<item android:drawable="@drawable/test_focused"
android:state_focused="true"/>
<item android:drawable="@drawable/test_normal"/>
</selector>
sau đó sẽ như thế nào tôi tham khảo button.xml trong bố cục của tôi?
<Button
...
android:???="button"/>
Cảm ơn!
Tôi là một chút nhầm lẫn với câu trả lời của bạn. Bạn có thể giải thích về điều này? Vì vậy, tôi sẽ tham khảo button.xml trong bố cục của tôi bằng cách sử dụng android: id = "button"? – user440308