Android 自定义圆角按钮
来源:互联网 发布:日军退子弹 知乎 编辑:程序博客网 时间:2024/05/29 16:42
Android 中自定义的控件经常要用到,下面是比较简单基础的。例子
res/drawable 目录下新建名为btn_bg.xml文件
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"><!--定义按钮的背景的颜色--> <solid android:color="#00CCFF"/> <!--设置按钮的每个角的弧度--> <corners android:radius="5dp"/> <!--按钮文字与边界的距离注意的地方,之前没有用到过--> <padding android:bottom="5dp" android:left="5dp" android:right="5dp" android:top="5dp"/></shape>
main.xml布局文件
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="圆角按钮" android:textSize="25dp" /> <Button android:layout_width="match_parent" android:layout_height="80dp" android:background="@drawable/btn_bg"→背景图片引用 android:text="自定义圆角按钮" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" style="?android:attr/buttonStyleInset"/></LinearLayout>
扩展:
style="?android:attr/buttonStyleInset"
@android:attr/button:普通按钮的效果
@android:attr/buttonBarButtonStyle:按钮栏的按钮效果
@android:attr/buttonBarStyle:按钮栏效果
@android:attr/buttonStyle:按钮的效果
@android:attr/buttonStyleInset:插入按钮的效果
@android:attr/buttonStyleSmall:小型按钮的效果
注:有些效果需要高级android SDK版本支持
@android:attr/buttonStyleToggle:选项按钮的效果
后续添加补充内容
源码地址:http://download.csdn.net/detail/csdnyuandaimaxuexi/9105529
0 0
- Android 自定义圆角按钮
- android自定义圆角按钮
- android圆角按钮自定义
- android自定义圆角动画按钮
- android自定义圆角动画按钮
- Android 自定义UI圆角按钮
- Androidの自定义圆角按钮button
- Android Shape自定义纯色圆角按钮
- Android 自定义UI圆角按钮
- Android Shape自定义圆角按钮
- Android Shape自定义纯色圆角按钮
- Android Shape自定义纯色圆角按钮
- Android Shape自定义纯色圆角按钮
- Android Shape自定义纯色圆角按钮
- Android自定义按钮之圆角矩形
- Android Shape自定义纯色圆角按钮
- 自定义圆角按钮
- Android开发之Shape自定义圆角按钮
- 数值型的特殊用法(可实现 var a=(5).plus(3).minus(6); //2)
- Mysql --常见小常识积累
- 利用Instruments中的Leaks处理内存泄露
- Java 1.7 Map类继承
- Android UI 之 Tab类型界面总结
- Android 自定义圆角按钮
- JavaWeb学习总结--JavaWeb开发入门
- 【javascript】arrayBuffer对象的理解
- OkHttp使用教程
- java 仿qq登陆界面
- ubuntu登录失败
- Linux下使用命令结束进程
- echarts添加点击事件
- 解决iOS首次启动app时,定位提示弹出框闪一下消失的情况。