android的Button默认写出来之后都是方形的直角,并且点击感很不明显,只要在drawable中加上一个xml就能解决这个问题:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> //点击时的样子
<shape android:shape="rectangle"> //显示为方形
<corners //显示为圆角
android:topLeftRadius="8dip"
android:topRightRadius="8dip"
android:bottomLeftRadius="8dip"
android:bottomRightRadius="8dip"/>
<solid android:color="@color/darkred"/> //背景颜色
</shape>
</item>
<item android:state_pressed="false"> //没点击时的样子
<shape android:shape="rectangle">
<corners
android:topLeftRadius="8dip"
android:topRightRadius="8dip"
android:bottomLeftRadius="8dip"
android:bottomRightRadius="8dip"/>
<solid android:color="@color/red"/>
</shape>
</item>
</selector>

我的xml命名是background_shape.xml,去掉我写的注释就直接能用,用法是在Button中加上:

android:background="@drawable/backguound_shape"

这样就能完成了。

最新文章

  1. [转载]IE678兼容性前缀区分
  2. c链表实现遇到的错误
  3. Unity3D在Windows的全屏和跨屏(双屏)方案
  4. Xcode编译异常和警告汇总(持续更新中)
  5. Add LUN to ASM in Linux
  6. 《Code Complete》ch.11 变量名的力量
  7. Maven SDK
  8. Myeclipse配置mybatis的xml自动提示
  9. HTTP状态码的意义
  10. MySQL之表的数据类型
  11. CRM之分页
  12. Codechef Bear and Clique Distances
  13. roc曲线和auc
  14. [转载]Windows&#160;2003&#160;R2&#160;SP2&#160;VOL&#160;企业版(简体中文)
  15. Django路由层
  16. Keepalived基础知识-运维小结
  17. Volley 结合GSON或FastJson用法
  18. [UE4]蓝图:重写父类时调用父类方法
  19. css基础 行内元素 块级元素
  20. UE和UI的区别

热门文章

  1. [BZOJ 4857][Jsoi2016]反质数序列
  2. 基础篇:6.1)形位公差-要素 Feature
  3. epoll_wait 返回值学习以及epoll使用学习
  4. 导项目jar包问题
  5. (转)Linux企业运维人员常用的150个命令分享
  6. pycurl安装问题
  7. Lvmetad is not active yet错误处理
  8. Linux上用户之间对话
  9. WPF的窗体设置WindowStyle=none时,如何移动窗体
  10. java获取request的头信息