Android 扁平化按钮
来源:互联网 发布:王思聪前女友淘宝店 编辑:程序博客网 时间:2024/06/11 23:43
View
创建 colors.xml 文件定义两个颜色
1. <resources>
2. <color name="blue_pressed">@android:color/holo_blue_dark</color>
3. <color name="blue_normal">@android:color/holo_blue_light</color>
4. </resources>
我们这里使用android的 HOLO 色调:
1. <!-- A dark Holo shade of blue -->
2. <color name="holo_blue_dark">#ff0099cc</color>
3. <!-- A light Holo shade of blue -->
4. <color name="holo_blue_light">#ff33b5e5</color>
创建 dimen.xml 文件,定义圆角值和阴影高度,见下图
1. <resources>
2. <dimen name="corner_radius">4dp</dimen>
3. <dimen name="layer_padding">3dp<<dimen>
4. </resources>
我们用shape来定义按钮背景 创建rect_pressed.xml 的 drawable 文件
1. <shape xmlns:android="http://schemas.android.com/apk/res/android"
2. android:shape="rectangle">
3. <corners android:radius="@dimen/corner_radius" />
4. <solid android:color="@color/blue_pressed" />
5. </shape>
创建rect_normal.xml file 的drawable 文件。
1. <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
2. <item android:drawable="@drawable/rect_pressed" />
3.
4. <item android:bottom="@dimen/layer_padding">
5. <shape android:shape="rectangle">
6. <corners android:radius="@dimen/corner_radius" />
7. <solid android:color="@color/blue_normal" />
8. </shape>
9. </item>
10. </layer-list>
为按钮定义 selector . 创建flat_selector.xml 文件。
1. <selector xmlns:android="http://schemas.android.com/apk/res/android">
2. <item android:state_pressed="true" android:drawable="@drawable/rect_pressed"/>
3. <item android:drawable="@drawable/rect_normal"/>
4. </selector>
定义 button 设置 background 为 flat_selector.
1. <Button
2. android:layout_width="fill_parent"
3. android:layout_height="wrap_content"
4. android:background="@drawable/flat_selector"
5. android:textColor="@android:color/white"
6. android:text="Say Hello" />
- Android 扁平化按钮
- Android 按钮的扁平化(圆角化)
- 按钮扁平化实现
- 设置扁平化按钮
- 扁平化按钮
- [Android]仿微信开关按钮:)扁平化简洁风
- Android开发_扁平化按钮的实现
- Android扁平化输入框和按钮(登录界面)
- 一个扁平化的H5按钮
- 简单又好看的扁平化按钮。
- 调节按钮亮度,调节扁平化
- Android UI——使用Drawable来实现扁平化的按钮
- 【Android开发】利用XML实现扁平化按钮和圆角矩形
- 简单又好看的按钮,扁平化按钮。
- 简单又好看的按钮,扁平化按钮.
- 简单又好看的按钮,扁平化按钮。
- 简单又好看的按钮,圆角扁平化按钮。
- 简单又好看的按钮,扁平化按钮。
- DP啊DP
- hdu 5012 bfs --- 慎用STL 比如MAP判重
- hdu4812 D Tree,平衡树,启发式合并
- 111111111111111
- C++中stack的deque实现
- Android 扁平化按钮
- hihocode的并查集&map
- 【Java.Web】JSP —— 语法基础 —— JSP异常处理
- 高精度(加法,乘法),字符串<->数值
- 手机女友服务体验1小时2014.10.05
- 24C02的工作原理
- 基于单片机蓝牙通信的安卓上位机应用
- 每天都在更新,我们的日子
- 序列的最长递增子序列长度 with matlab