I need to add a border to my button when it’s clicked, and i need the background from the button (which i get remotely, so i cant use R.drawable.picture etc) to remain the way it is.
In short, when clicked, i want to add a border to my (custom backgrounded) button.
How do i do this? I’ve read many many pages and questions on borders, buttons, shapes, selectors, etc, but the majority of them involve xml, but because i don’t have the background from the buttons before starting the applications, I think i’m bound to programmatically adding and removing the border. Again, i need to retain the custom button background, but add a small onclick border.
NOTE: I use this on all buttons, with different sizes. So applying a drawable is not a real option. I think i’m bound to some sort of drawing a rectangle around the clicked button.
NOTE2: again, I have a background which must be applied. the border is merely a small indicator for onclick events. So i cant put in the XML that the background is some sort of selector
You can define layer_list in xml with 2 layers: one for your image, the other one for your border and use this layer list as a drawable for your button’s pressed state