I am using an ImageButton
. But I don get the highlight when clicked. I googled and many suggested to use selector where another image is displayed. Is there any way
I managed to do this!! First you declare buttonStyle.xml in drawable folder.
Then you create button_pressed.xml in drawable folder.
After that, you create button_normal.xml in drawable folder.
You can use default colors but if you want to do it like me, you need to have a file named colors.xml in values folder and this values inside:
- #2A3748
- #602A3748
- @color/gnfrBlueColor
- @color/semiTransparentGnfrBlueColor
Finally you set this to your button or whatever:
savedAccountLoginButton.SetBackgroundResource(Resource.Drawable.buttonStyle);
NOTICE THAT I set a stroke with color transparent because when you set backgroundresource your button becomes bigger and with this trick it remains original.
This is the only way I could archieve this programmatically.
If you want to do this by XML: