引用:http://blog.sina.com.cn/s/blog_73e890f40100vpm3.html

从网上找了好多的资料,最后自己研究加借鉴人家的经验得出的结果是最简单的,现在拿出来晒晒

1.在res下新建一个drawable文件夹

2.在drawable中定义圆角按钮的文件btn1.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@drawable/btn_blue"/>
<stroke android:width="1dp" color="@drawable/btn_blue"/>
<padding android:left="1dp"
android:top="1dp"
android:right="1dp"
android:bottom="1dp"
/>
<corners android:bottomRightRadius="3dp"
android:bottomLeftRadius="3dp"
android:topLeftRadius="3dp"
android:topRightRadius="3dp"
/>


</shape>

3.在Activity代码中使用 或是 在xml布局文件中直接 android:background="@drawable/..."

int color=R.drawable.按钮配置文件名

Resources res=getResources();
Drawable draw=res.getDrawable(color);
btn.setBackgroundDrawable(draw);
OK,简简单单搞定

更多相关文章

  1. conversion to dalvik format failed with error 1 错误解决方案
  2. android中的资源使用
  3. 文件接收网络对讲机C#服务器 Android客户端(二) C#服务器代码分析
  4. 【Android(安卓)Developers Training】 24. 保存键值对
  5. Android(安卓)下载zip压缩文件并解压
  6. Android(安卓)手机上传图片至javaweb服务器(servlet)
  7. Android2.2快速入门 zz
  8. Android(安卓)点击两次退后按钮程序退出
  9. Androidstudio打包jar和arr包

随机推荐

  1. 【总结】layout_below与layout_alignBott
  2. 修改AndroidStudio默认的compileSdkVersi
  3. Mac 安装 Android Studio 以及 Android
  4. Android广播
  5. 通過android selector改变界面状态
  6. Android定义字符串数组资源并在程序中使
  7. unsupported dynamic reloc R_ARM_REL32
  8. Android系统属性SystemProperties分析
  9. Android(安卓):动画的使用(1)
  10. Android 中文API (33) —— Checkable