效果图:
首先我们写button的样式:在 drawable目录 下新建 button_bg_style.xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<!--填充色-->
<solid android:color="@android:color/transparent"/>
<!--边框的宽 和 边框颜色-->
<stroke android:width="0.5px" android:color="@android:color/holo_red_dark"/>
<!--按钮的四个角为 弧角 -->
<!-- 弧角radius 半径-->
<corners android:radius="10dp"/>
</shape>然后在使用button的时候,将样式加到background上:
就能达到上面效果啦!
本文介绍如何在Android中通过自定义XML文件来实现具有特定背景样式的Button。具体步骤包括创建一个包含透明填充色、暗红色边框及圆角的矩形形状资源,并将其应用于Button的背景属性上。
2660

被折叠的 条评论
为什么被折叠?



