i have a button with two states(selected and unselected). the image of button is different for the states. Which one should I use? How do i set images and states? Please give suggestions(i am new to android).
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.
Use an xml configuration within the drawable folder. Instead of referencing the image as background for your button, you reference this xml configuration (file name):
E.g: my_button.xml
Use in layout.xml:
With this configuration you can influence the appearance of the button, when pressed, focused and so on. Its the same way for both types of buttons (Button and ImageButton). If your button contains no text, use ImageButton.