I have made my button transparent so I would like to have the button text color change when the button is pressed. Is it possible to do this using just xml files?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
See the section called State List in this bit of documentation…Drawable Resources.
You can define two different
Buttonxml files one for the transparent ‘default’ state and another with the button as Red for your ‘pressed’ state. You then define aselectorwhich switches the drawable resources in the different states.EDIT: As per devunwired’s comment the Color State List resource is probably more suitable for just changing colours rather than the drawable itself.