Blue button

?
01 02 03 04 05 06 07 08 09 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 <? xml version = "1.0" encoding = "utf-8" ?> < selector xmlns:android = "http://schemas.android.com/apk/res/android" > < item android:state_pressed = "true" > < shape > < solid android:color = "#449def" /> < stroke android:width = "1dp" android:color = "#2f6699" /> < corners android:radius = "3dp" /> < padding android:left = "10dp" android:top = "10dp" android:right = "10dp" android:bottom = "10dp" /> </ shape > </ item > < item > < shape > < gradient android:startColor = "#449def" android:endColor = "#2f6699" android:angle = "270" /> < stroke android:width = "1dp" android:color = "#2f6699" /> < corners android:radius = "4dp" /> < padding android:left = "10dp" android:top = "10dp" android:right = "10dp" android:bottom = "10dp" /> </ shape > </ item > </ selector >

Red button

?
01 02 03 04 05 06 07 08 09 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 <? xml version = "1.0" encoding = "utf-8" ?> < selector xmlns:android = "http://schemas.android.com/apk/res/android" > < item android:state_pressed = "true" > < shape > < solid android:color = "#ef4444" /> < stroke android:width = "1dp" android:color = "#992f2f" /> < corners android:radius = "3dp" /> < padding android:left = "10dp" android:top = "10dp" android:right = "10dp" android:bottom = "10dp" /> </ shape > </ item > < item > < shape > < gradient android:startColor = "#ef4444" android:endColor = "#992f2f" android:angle = "270" /> < stroke android:width = "1dp" android:color = "#992f2f" /> < corners android:radius = "3dp" /> < padding android:left = "10dp" android:top = "10dp" android:right = "10dp" android:bottom = "10dp" /> </ shape > </ item > </ selector >

Purple button

?
01 02 03 04 05 06 07 08 09 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 <? xml version = "1.0" encoding = "utf-8" ?> < selector xmlns:android = "http://schemas.android.com/apk/res/android" > < item android:state_pressed = "true" > < shape > < solid android:color = "#a276eb" /> < stroke android:width = "1dp" android:color = "#6a3ab2" /> < corners android:radius = "3dp" /> < padding android:left = "10dp" android:top = "10dp" android:right = "10dp" android:bottom = "10dp" /> </ shape > </ item > < item > < shape > < gradient android:startColor = "#a276eb" android:endColor = "#6a3ab2" android:angle = "270" /> < stroke android:width = "1dp" android:color = "#6a3ab2" /> < corners android:radius = "4dp" /> < padding android:left = "10dp" android:top = "10dp" android:right = "10dp" android:bottom = "10dp" /> </ shape > </ item > </ selector >

Green button

?
01 02 03 04 05 06 07 08 09 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 <? xml version = "1.0" encoding = "utf-8" ?> < selector xmlns:android = "http://schemas.android.com/apk/res/android" > < item android:state_pressed = "true" > < shape > < solid android:color = "#70c656" /> < stroke android:width = "1dp" android:color = "#53933f" /> < corners android:radius = "3dp" /> < padding android:left = "10dp" android:top = "10dp" android:right = "10dp" android:bottom = "10dp" /> </ shape > </ item > < item > < shape > < gradient android:startColor = "#70c656" android:endColor = "#53933f" android:angle = "270" /> < stroke android:width = "1dp" android:color = "#53933f" /> < corners android:radius = "4dp" /> < padding android:left = "10dp" android:top = "10dp" android:right = "10dp" android:bottom = "10dp" /> </ shape > </ item > </ selector >

Yellowbutton

?
01 02 03 04 05 06 07 08 09 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 <? xml version = "1.0" encoding = "utf-8" ?> < selector xmlns:android = "http://schemas.android.com/apk/res/android" > < item android:state_pressed = "true" > < shape > < solid android:color = "#f3ae1b" /> < stroke android:width = "1dp" android:color = "#bb6008" /> < corners android:radius = "3dp" /> < padding android:left = "10dp" android:top = "10dp" android:right = "10dp" android:bottom = "10dp" /> </ shape > </ item > < item > < shape > < gradient android:startColor = "#f3ae1b" android:endColor = "#bb6008" android:angle = "270" /> < stroke android:width = "1dp" android:color = "#bb6008" /> < corners android:radius = "4dp" /> < padding android:left = "10dp" android:top = "10dp" android:right = "10dp" android:bottom = "10dp" /> </ shape > </ item > </ selector >

Blackbutton

?
01 02 03 04 05 06 07 08 09 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 <? xml version = "1.0" encoding = "utf-8" ?> < selector xmlns:android = "http://schemas.android.com/apk/res/android" > < item android:state_pressed = "true" > < shape > < solid android:color = "#343434" /> < stroke android:width = "1dp" android:color = "#171717" /> < corners android:radius = "3dp" /> < padding android:left = "10dp" android:top = "10dp" android:right = "10dp" android:bottom = "10dp" /> </ shape > </ item > < item > < shape > < gradient android:startColor = "#343434" android:endColor = "#171717" android:angle = "270" /> < stroke android:width = "1dp" android:color = "#171717" /> < corners android:radius = "4dp" /> < padding android:left = "10dp" android:top = "10dp" android:right = "10dp" android:bottom = "10dp" /> </ shape > </ item > </ selector >

All text on the buttons will have the same styleso we can define a style in strings.xml:

?
01 02 03 04 05 06 07 08 09 10 11 12 13 < style name = "ButtonText" > < item name = "android:layout_width" >fill_parent</ item > < item name = "android:layout_height" >wrap_content</ item > < item name = "android:textColor" >#ffffff</ item > < item name = "android:gravity" >center</ item > < item name = "android:layout_margin" >3dp</ item > < item name = "android:textSize" >30dp</ item > < item name = "android:textStyle" >bold</ item > < item name = "android:shadowColor" >#000000</ item > < item name = "android:shadowDx" >1</ item > < item name = "android:shadowDy" >1</ item > < item name = "android:shadowRadius" >2</ item > </ style >
调用 :

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"    android:orientation="vertical">   <Button android:text="Button" android:id="@+id/button1" android:background="@drawable/btn_red" style="@style/ButtonText"></Button>   <Button android:text="Button" android:id="@+id/button2" android:background="@drawable/btn_blue" style="@style/ButtonText"></Button>   <Button android:text="Button" android:id="@+id/button3" android:background="@drawable/btn_purple" style="@style/ButtonText"></Button>   <Button android:text="Button" android:id="@+id/button4" android:background="@drawable/btn_green" style="@style/ButtonText"></Button>   <Button android:text="Button" android:id="@+id/button5" android:background="@drawable/btn_orange" style="@style/ButtonText"></Button>   <Button android:text="Button" android:id="@+id/button6" android:background="@drawable/btn_black" style="@style/ButtonText"></Button></LinearLayout>






更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android(安卓)到ARM versatile PB板移植
  2. Android(安卓)Studio 使用NDK编译时常见
  3. android中tabhost的使用
  4. android点击系统通知Notification,进入指
  5. 简单android Service 创建与启动示例
  6. Android(安卓)ApiDemos示例解析(108):Vie
  7. Android设置角标提示
  8. 学习android网址
  9. Android(安卓)Bitmap 圆角
  10. Android(安卓)sdk 接入时遇到的错误解决