Guest User

Untitled

a guest
Apr 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. # With the Support Library v7, all the styles are actually already defined and ready to use, for the standard buttons, all of these styles are available:
  2. style="@style/Widget.AppCompat.Button"
  3. style="@style/Widget.AppCompat.Button.Colored"
  4. style="@style/Widget.AppCompat.Button.Borderless"
  5. style="@style/Widget.AppCompat.Button.Borderless.Colored"
  6.  
  7. # Step 1: Define the system colors in your style. (The buttom with above styles use accent color)
  8. <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  9. <item name="colorPrimary">@color/colorPrimary</item>
  10. <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
  11. <item name="colorAccent">@color/colorAccent</item>
  12. </style>
  13.  
  14. # Step 2: Define your style in the buttom
  15. <Button style="@style/Widget.AppCompat.Button.Colored"
  16. [...]
  17. android:text="Button"/>
  18.  
  19. # For a specific button:
  20.  
  21. 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:
  22.  
  23. <style name="AppTheme.Button" parent="Widget.AppCompat.Button.Colored">
  24. <item name="colorButtonNormal">@color/your_color_buttom</item>
  25. <item name="android:textColor">@color/your_text_color</item>
  26. </style>
  27.  
  28. - Then you just need to apply this new style on the button with:
  29.  
  30. android:theme="@style/AppTheme.Button"
  31.  
  32. - To set a default button design in a layout, add this line to the styles.xml theme:
  33.  
  34. <item name="buttonStyle">@style/AppTheme.Button</item>
  35.  
  36. This sets the button style for all the buttons in a layout with a specific theme
Add Comment
Please, Sign In to add comment