标签:android style http ar io color os 使用 sp
我也是用线性布局当做一个按钮,我没有绑定任何点击事件,它就能够工作,我为标准的按钮建立了一个样式,我只是不停的分配样式到按钮
把 linearlayout 当成一个 button:
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
|
< LinearLayout style = "@style/btn_stand" android:layout_width = "match_parent" android:layout_height = "wrap_content" android:onClick = "onClickLLButton" android:orientation = "vertical" > < TextView android:layout_width = "match_parent" android:layout_height = "wrap_content" android:gravity = "center" android:text = "Button Label" /> < TextView android:id = "@+id/tvLLButton" android:layout_height = "0px" android:layout_weight = "1" android:gravity = "center" android:text = "Button Info" /> </ LinearLayout > My style definition for the button: < style name = "btn_stand" parent = "AppBaseTheme" > < item name = "android:background" >@drawable/btn_stand_sel</ item > < item name = "android:textColor" >@drawable/btn_stand_text_color</ item > < item name = "android:minHeight" >48dp</ item > < item name = "android:paddingLeft" >5dp</ item > < item name = "android:paddingRight" >5dp</ item > </ style > |
我的@drawable/btn_stan_sel 文件:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<? xml version = "1.0" encoding = "utf-8" ?> < selector xmlns:android = "http://schemas.android.com/apk/res/android" > <!-- disabled state --> < item android:drawable = "@drawable/btn_stand_disabled" android:state_enabled = "false" /> <!-- enabled and pressed state --> < item android:drawable = "@drawable/btn_stand_pressed" android:state_enabled = "true" android:state_pressed = "true" /> <!-- enabled and focused state --> < item android:drawable = "@drawable/btn_stand_focused" android:state_enabled = "true" android:state_focused = "true" /> <!-- enabled state --> < item android:drawable = "@drawable/btn_stand_enabled" android:state_enabled = "true" /> </ selector > |
我的绘制文件为重复的为每一个状态绘制不同的颜色
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<? xml version = "1.0" encoding = "utf-8" ?> < shape xmlns:android = "http://schemas.android.com/apk/res/android" android:shape = "rectangle" > < stroke android:width = "1dp" android:color = "@color/stroke" /> < solid android:color = "@color/blue" /> < corners android:radius = "6dp" /> </ shape > |
原文地址:http://www.itmmd.com/201411/186.html
该文章由 萌萌的IT人 整理发布,转载须标明出处。
Android的LinearLayout中 selector背景颜色
标签:android style http ar io color os 使用 sp
原文地址:http://blog.csdn.net/dyllove98/article/details/41960593