android发开,怎样用xml画一个带圆角的白色边框?
时间: 2024-03-01 07:52:26 浏览: 16
您可以使用`shape`标签和`corners`标签来绘制一个带圆角的白色边框,具体步骤如下所示:
1. 在`res/drawable`目录下新建一个xml文件,例如`white_round_border.xml`。
2. 在`white_round_border.xml`文件中添加以下代码:
```
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/white" />
<corners android:radius="10dp" />
<stroke
android:width="2dp"
android:color="@android:color/white" />
</shape>
```
3. 将`android:radius`属性设置为所需的圆角半径大小,将`android:width`属性设置为所需的边框宽度大小。
4. 在布局文件中使用该drawable即可实现带圆角的白色边框效果,例如:
```
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:background="@drawable/white_round_border" />
```
这样就可以实现一个带圆角的白色边框了。