免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1634 | 回复: 1
打印 上一主题 下一主题

[Android] 按钮,圆形按钮,带文字的图片按钮 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2015-07-24 14:04 |只看该作者 |倒序浏览

Demo2\button_demo\src\main\res\drawable\button_selector.xml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <selector xmlns:android="http://schemas.android.com/apk/res/android">
  3.     <item android:state_pressed="true" android:drawable="@mipmap/favoured_icon"></item>
  4.     <item android:state_pressed="false" android:drawable="@mipmap/s_rate_crown"></item>
  5. </selector>
复制代码
Demo2\button_demo\src\main\res\layout\activity_main.xml
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2.     xmlns:tools="http://schemas.android.com/tools"
  3.     android:layout_width="match_parent"
  4.     android:layout_height="match_parent"
  5.     android:orientation="vertical"
  6.     tools:context=".MainActivity">
  7.     <!--文字带阴影的按钮-->
  8.     <Button
  9.         android:layout_width="wrap_content"
  10.         android:layout_height="wrap_content"
  11.         android:shadowColor="#aa5"
  12.         android:shadowDx="5"
  13.         android:shadowDy="5"
  14.         android:shadowRadius="1"
  15.         android:text="文字带阴影的按钮"
  16.         android:textSize="12dp" />
  17.     <!--普通的文字按钮-->
  18.     <Button
  19.         android:layout_width="wrap_content"
  20.         android:layout_height="wrap_content"
  21.         android:background="#ff1827"
  22.         android:text="普通按钮"
  23.         android:textSize="10dp" />
  24.     <!--带文字的图片按钮-->
  25.     <Button
  26.         android:layout_width="wrap_content"
  27.         android:layout_height="wrap_content"
  28.         android:background="@drawable/button_selector"
  29.         android:text="带文字的图片按钮"
  30.         android:textSize="11dp" />
  31. </LinearLayout>
复制代码

论坛徽章:
59
2015七夕节徽章
日期:2015-08-24 11:17:25ChinaUnix专家徽章
日期:2015-07-20 09:19:30每周论坛发贴之星
日期:2015-07-20 09:19:42ChinaUnix元老
日期:2015-07-20 11:04:38荣誉版主
日期:2015-07-20 11:05:19巳蛇
日期:2015-07-20 11:05:26CU十二周年纪念徽章
日期:2015-07-20 11:05:27IT运维版块每日发帖之星
日期:2015-07-20 11:05:34操作系统版块每日发帖之星
日期:2015-07-20 11:05:36程序设计版块每日发帖之星
日期:2015-07-20 11:05:40数据库技术版块每日发帖之星
日期:2015-07-20 11:05:432015年辞旧岁徽章
日期:2015-07-20 11:05:44
2 [报告]
发表于 2015-08-11 15:42 |只看该作者
各种形状的按钮。多给点DEMO。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP