Alex
Alex

Reputation: 1175

How to change a styled button background colour without having to create a drawable for each of them?

I need to apply a "double-layered" background to a button (or a view with an OnClickListener): the layer below is solid-coloured, the layer above is a frame.
Is there a way to change the colour on the go?
enter image description here

Upvotes: 0

Views: 24

Answers (1)

Andrei Tudor Diaconu
Andrei Tudor Diaconu

Reputation: 2257

You could just try and have 2 views instead of one. You could have a LinearLayout with a ImageView inside it. The LinearLayout would have the colour you want and the ImageView would just be rendered on top of the LinearLayout background, unchanged.

Upvotes: 2

Related Questions