android实现控件边框效果
在Android中,有一种特殊的图形,成为shape,在使用图片的地方,基本上可以使用shape,他能实现圆角,边框,渐变等功能。1、定义圆角shape在drawable文件夹下新建一个shape_border_color_primary.xml文件<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http:/
·
在Android中,有一种特殊的图形,成为shape,在使用图片的地方,基本上可以使用shape,他能实现圆角,边框,渐变等功能。
1、定义圆角shape
在drawable文件夹下新建一个shape_border_color_primary.xml文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<!--圆角的大小-->
<!--控件高度的一半-->
<corners android:radius="20dp"/>
<!--填充颜色-->
<!--@android中定义了一些颜色,可以自己查看使用-->
<solid android:color="@android:color/white"/>
<!--边框-->
<stroke
android:width="1dp"
android:color="@android:color/holo_blue_bright"/>
</shape>
2、通过控件的background属性引入,实现控件边框效果
<Button
android:background="@drawable/shape_border_color_primary"
android:layout_width="wrap_content"
android:layout_height="40dp"/>
更多推荐
已为社区贡献5条内容
所有评论(0)