标签:android class blog c code java
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 |
drawable/button_color.xml <?xml version="1.0"
encoding="utf-8"?> <item android:state_pressed="true"> <!-- 定义当button 处于pressed 状态时的形态。--> <shape> <gradient android:startColor="#8600ff"
/> <stroke android:width="2dp"
android:color="#000000"
/> <corners android:radius="5dp"
/> <padding android:left="10dp"
android:top="10dp" android:bottom="10dp"
android:right="10dp"
/> </shape> </item> <item android:state_focused="true"> <!-- 定义当button获得focus时的形态--> <shape> <gradient android:startColor="#eac100"
/> <stroke android:width="2dp"
android:color="#333333"
color="#ffffff"
/> <corners android:radius="8dp"
/> <padding android:left="10dp"
android:top="10dp" android:bottom="10dp"
android:right="10dp"
/> </shape> </item></selector> |
最后,需要在包含button的xml文件里添加两项。假如是activity_main.xml 文件,我们需要在<Button />里加两项。
android:focusable="true"
android:backgroud="@drawable/button_color"
这样当你使用Button的时候就可以甩掉系统自带的那黄颜色的背景了,实现个性化的背景,配合应用的整体布局非常之有用啊
标签:android class blog c code java
原文地址:http://www.cnblogs.com/xiaosw/p/3741652.html