Android 设置背景边框
摘自:http://blog.csdn.net/aminfo/article/details/7782253
以下是设置按钮的右边框和底边框颜色为红色,边框大小为3dp,如下图:

在drawable新建一个 buttonstyle.xml的文件,内容如下:
[html] view plain copy- xml version="1.0" encoding="UTF-8"?>
- <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
- <item>
- <shape>
- <solid android:color="#ff0000" />
- shape>
- item>
- <item android:bottom="3dp" android:right="3dp">
- <shape>
- <solid android:color="#ffffff" />
- <padding android:bottom="10dp"
- android:left="10dp"
- android:right="10dp"
- android:top="10dp" />
- shape>
- item>
- layer-list>
然后在布局文件里面的Button里面设置如下:
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button1"
- android:background="@drawable/buttonstyle" />
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
