I'm making a tic tac toe program. I can get the button to display X or 0 but I can not get them to display different colors How do i do this
Use a selector to change the color of the button when clicked.
/res/drawable/btn_selector.xml
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Selector xmlns: Android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Item Android: state_pressed = "true" & gt; & Lt; Size & gt; & Lt; Solid Android: Color = "# FFAA 66" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt; Items & gt; & Lt; Size & gt; & Lt; Solid Android: Color = "# ffdd99" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt; / Selector & gt;
And now apply this xml to android: background
on the button.
No comments:
Post a Comment