user1733468
user1733468

Reputation: 41

Button got smaller when the background color is changed

I have a button whose background color I changed with this: android:background="#C0C0C0" and on the emulator, the button is smaller than it was when I didn't have a background color. Is that normal? Thank you.

Upvotes: 0

Views: 68

Answers (2)

dangVarmit
dangVarmit

Reputation: 5661

Yes, it is normal for Button, because the default background image is a nine-patch that defines padding. The padding is added to the size of the text, so when you set the button to just a color, the padding is removed and your button gets smaller.

Upvotes: 1

Ogen
Ogen

Reputation: 6709

Add these two to your button element:

android:scaleType="fitXY"
android:padding="0dp"

Upvotes: 0

Related Questions