Violet Giraffe
Violet Giraffe

Reputation: 33617

Android UI: setting background color for Button prevents it from highlighting upon press

I need to eliminate the gap between buttons in a layout. I'm doing it by setting background color for a style and applying that style to my buttons. This eliminates the highlighting upon press, which I of course need. Here is a solution to this problem, but it requires extra actions to be taken with Java code. Can I make it statically, only with XMLs?

Also, if there is any other way to remove the gap without changing the other aspects of button's appearance - please suggest. The only requirement is it should be done with XML (however, if no other options exist, I can inherit Button class).

Upvotes: 0

Views: 281

Answers (1)

Vladimir
Vladimir

Reputation: 9753

You can use StateList xml for background of your button

Upvotes: 3

Related Questions