I have an ImageButton which is disabled (non clickable or set as disabled). I want to give an UI feel to the user that it is disabled without using any other image.
Is there any way to do this?
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.
Unlike a regular
Button, anImageButtonor aButtonthat has an image background is not grayed when disabled. You actually have to use another image or to process it in a way it appears grayed.Should using another image be ok, you can do this by using a
<selector>(here associated to a regularButtonbut this amongs to the same):/drawable/my_selector.xml:Please note that in a selector the logic applies a sequential way, item per item. Here,
button_redis used all the time but when the button is disabled or being pushed.Your
layout.xml:And should using another image be a problem, other answers (such as @Tronman’s or @southerton’s) give you ways to programmatically process the image in a way it appears grayed.