android的EditText边框选择颜色
时间: 2023-10-23 12:18:55 浏览: 55
可以通过在EditText的xml文件中使用以下属性来选择边框颜色:
1. background:设置EditText的背景颜色,可以使用color或drawable资源文件。
2. borderColor:设置EditText边框的颜色,可以使用color资源文件。
3. borderWidth:设置EditText边框的宽度,可以使用dimension资源文件。
示例代码:
```
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edittext_background"
android:borderColor="@color/edittext_border_color"
android:borderWidth="2dp"/>
```
其中,edittext_background.xml的内容如下:
```
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@android:color/white"/>
<stroke android:width="2dp" android:color="@color/edittext_border_color"/>
<corners android:radius="5dp"/>
</shape>
```
edittext_border_color的值可以根据需求自行定义。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)