当前位置 : 主页 > 网页制作 > xml >

xml模版,自定义按钮背景

来源:互联网 收集:自由互联 发布时间:2021-08-18
xml模版,自定义按钮背景 ?xml version=1.0 encoding=utf-8?corners android:bottomleftradius=4dp android:bottomRightRadius=4dpandroid:topLeftRadius=4dpandroid:topRightRadius=4dp/paddingandroid:bottom=1dpandroid:left=1dpandroid:right=1
xml模版,自定义按钮背景

<?xml version="1.0" encoding="utf-8"?>

<corners android:bottomleftradius="4dp" android:bottomRightRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp"/>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp"/>


<corners android:bottomleftradius="4dp" android:bottomRightRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp"/>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp"/>

最外层是选择器,里面包含两个item的state_pressed属性会被被点击时触发,true表示显示被点击的item,false是默认值,显示没被点击的里面包含,的shape属性可以控制显示的形状,一般选择 rectangle 矩形或者oval 椭圆,如果希望能成圆形,需要限定高度等于宽度并且大于文本的宽度才行,在节点添加

<size android:width="130dp" android:height="130dp" />

里面包含的内容非常丰富

填充颜色

边线 width:边线宽度 color:颜色 dashWidth:虚线宽度,dashGap:虚线间隔宽度圆角,可以设置四个边角,此时shape是矩形,也可以一次性设置radius

设置宽度和高度

设置内边距

以上就是xml模版,自定义按钮背景的详细内容,更多请关注自由互联其它相关文章!

网友评论