实现Material Design风格的Button
来源:互联网 发布:python 显示 数码相框 编辑:程序博客网 时间:2024/04/29 06:09
实现Material Design风格的Button
简介
The AppCompat Support Library 定义了几个很有用的style,这些Style是基于Widget.AppCompat.Button style实现的。当使用 AppCompat theme主题的时候,Widget.AppCompat.Button style 是默认使用到所有的button上面的。这些样式保证了Button看起来都是一样的,并且都是遵守了material design风格。
在这种情况下,最接近的颜色是粉色。
1.最常见的Button效果
Simple Button: @style/Widget.AppCompat.Button
<Button style="@style/Widget.AppCompat.Button" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" android:text="@string/simple_button"/>
第二个样式
Colored Button: @style/Widget.AppCompat.Button.Colored
The Widget.AppCompat.Button.Colored 继承了 Widget.AppCompat.Button style并且根据你选择的主题应用最接近的颜色。
<Button style="@style/Widget.AppCompat.Button.Colored" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" android:text="@string/colored_button"/>
2.定制Button的背景颜色
如果你想定制背景颜色,你可以定制一个主题,使用android:theme这个属性,继承自ThemeOverlay主题。
<Button style="@style/Widget.AppCompat.Button.Colored" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="16dp" android:theme="@style/MyButtonTheme"/> defining the following theme: <!-- res/values/themes.xml --> <style name="MyButtonTheme" parent="ThemeOverlay.AppCompat.Light"> <item name="colorAccent">@color/my_color</item> </style>
3.Borderless Button
代码示例
Borderless Button: @style/Widget.AppCompat.Button.Borderless<Button style="@style/Widget.AppCompat.Button.Borderless" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" android:text="@string/borderless_button"/>
Borderless Colored Button
@style/Widget.AppCompat.Button.Borderless.Colored<Button style="@style/Widget.AppCompat.Button.Borderless.Colored" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="16dp" android:text="@string/borderless_colored_button"/>
帮朋友招聘职位
普照天星【Java开发工程师】20-30k
http://www.jianshu.com/p/8b52751360df
产品经理20-30k
http://www.jianshu.com/p/cb0ac7a00796
我的微信二维码如下
微信订阅号二维码如下:
2 0
- 实现Material Design风格的Button
- 实现Material Design水波效果的Button
- 打造极致Material Design动画风格Button
- Material Design风格SearchView实现
- 实现Material Design风格的点击水波荡漾效果
- 使用 DrawerLayout 实现 Material Design风格的侧滑
- Android Toolbar详解-实现Material Design 风格的导航栏
- Material Design Button 的 disable 效果
- Material Design控件Button,CheckBox的使用
- Material Design风格的下拉刷新
- Material Design风格的侧边抽屉栏
- Android:自定义Material Design风格的Dialog
- 自定义 Material Design风格的提示框
- 打造Material Design风格的TabBar
- 自定义material design 风格的Dialog
- material design风格的收缩日历
- Material Design风格控件的使用
- Android:自定义Material Design风格的Dialog
- 椭圆线条绘制动画
- c#用StreamReader对文件读取
- 如何使用场景法设计测试用例
- synchronized静态方法的使用
- PopupWindow实现右侧、左侧和底部弹出菜单
- 实现Material Design风格的Button
- 基于Keras的CNN框架
- Linux基础-文件查找
- Hibernate:unexpected end of subtree 异常
- YSCB来测试MongoDB
- android:一行代码实现沉浸式布局效果
- 装箱,拆箱,枚举,Tostring()+num.Tostring()为什么不属于装箱?
- 软件工程文档总结
- session机制详解