How to change the color
For the whole app:
The color of all the UI controls (not only buttons, but also floating action buttons, checkboxes etc.) is managed by the attribute colorAccent as explained here. You can modify this style and apply your own color in your theme definition:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="colorAccent">@color/Orange</item>
</style>
For a specific button:
If you need to change the style of a specific button, you can define a new style, inheriting one of the parent styles described above. In the example below I just changed the background and font colors:
<style name="AppTheme.Button" parent="Widget.AppCompat.Button.Colored">
<item name="colorButtonNormal">@color/Red</item>
<item name="android:textColor">@color/White</item>
</style>
Then you just need to apply this new style on the button with:
android:theme="@style/AppTheme.Button"
To set a default button design in a layout, add this line to the styles.xml theme:
<item name="buttonStyle">@style/btn</item>
where @style/btn is your button theme. This sets the button style for all the buttons in a layout with a specific theme
'소프트웨어 개발 > Android' 카테고리의 다른 글
Using Java variables declared in Gradle (0) | 2018.06.01 |
---|---|
The map of Android UI/UX v0.3 (0) | 2018.05.22 |