Material Design Button 样式
2016-09-08 18:09
323 查看
132down voteaccepted | I will add my answer since I don't use any of the other answers provided. 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: style="@style/Widget.AppCompat.Button" style="@style/Widget.AppCompat.Button.Colored" style="@style/Widget.AppCompat.Button.Borderless" style="@style/Widget.AppCompat.Button.Borderless.Colored" Widget.AppCompat.Button: Widget.AppCompat.Button.Colored: Widget.AppCompat.Button.Borderless Widget.AppCompat.Button.Borderless.Colored: To answer the question, the style to use is therefore style="@style/Widget.AppCompat.Button.Colored". How to change the colorFor 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 colorAccentas 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" |
相关文章推荐
- CSS书写顺序
- 小三角的css画法(两种)
- CSS学习笔记之position定位
- html,css网页兼容问题
- 值得一记的开发css小技巧
- CSS学习笔记之文档流
- css只显示两行 超过显示点点点
- CSS学习笔记之背景属性
- CSS3之过渡Transition
- css中px,em和rem的区别
- html引用css
- 纯CSS绘制三角形(各种角度)
- CSS3 pointer-events:none应用举例及扩展
- WEB前端性能优化:HTML,CSS,JS和服务器端优化
- CSS之DIV布局样式class
- 使用CSS隐藏HTML元素的4种常用方法
- 关于自适应布局box 与 flex
- CSS样式中” 大于号”
- CSS hack
- css清浮动方法