When you set android:background
to another color, the Button
appears more bigger. Also, the lines surrounding the Button
is gone. Why is this?
Asked
Active
Viewed 228 times
2

so5user5
- 325
- 1
- 16
-
1When you set color it draws rectangle area by this color but default it can use some drawable or nine patch picture – Denis Sologub Feb 10 '16 at 00:30
-
Oh, thanks. I'm using Marshmallow target, must be the Appcompat. – so5user5 Feb 10 '16 at 00:30
-
You should add that as an answer so I could nominate it. – so5user5 Feb 10 '16 at 00:31
-
Use [shape](http://developer.android.com/intl/ru/guide/topics/resources/drawable-resource.html#Shape) to customize background – Denis Sologub Feb 10 '16 at 00:31
-
You should be using [this answer](http://stackoverflow.com/a/26686433/1676363) if you want to colorize a button but keep all the standard styling/look and feel – ianhanniballake Feb 10 '16 at 00:33
-
Thanks, all. It's a duplicate, seems so. – so5user5 Feb 10 '16 at 02:10
1 Answers
1
When you set color it draws rectangle area by this color but default it can use some drawable or nine patch picture. Use shape to customize background or override styles. If you need to apply style only for some view you can use xml attribute style
.
<style name="MyCoolStyle" parent="base style of view" >
</style>
In layout xml:
<YourView
style="@style/MyCoolStyle"/>

Denis Sologub
- 7,277
- 11
- 56
- 123