android EditText 圆弧形 白色
时间: 2024-01-08 14:02:42 浏览: 26
你可以使用以下代码将 `EditText` 变成圆弧形白色:
```
<EditText
android:background="@drawable/edit_text_background"
... />
```
然后在 `res/drawable` 文件夹下创建 `edit_text_background.xml` 文件,代码如下:
```
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/white" />
<corners android:radius="20dp" />
<stroke
android:width="1dp"
android:color="@android:color/darker_gray" />
</shape>
```
其中 `android:radius` 属性用于设置圆角半径大小,可以根据需要进行调整。
相关问题
android EditText 圆弧形
要将 Android EditText 控件设置为圆弧形,需要进行以下步骤:
1. 创建一个 drawable 资源文件,例如 `round_edittext.xml`,并设置 `shape` 为 `rectangle`,同时设置 `corners` 属性为半径大小,例如:
```xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:padding="10dp">
<corners
android:bottomRightRadius="20dp"
android:bottomLeftRadius="20dp"
android:topLeftRadius="20dp"
android:topRightRadius="20dp" />
</shape>
```
2. 在布局文件中,将 EditText 的背景属性设置为刚刚创建的 drawable 资源文件,例如:
```xml
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/round_edittext" />
```
这样就可以将 EditText 控件设置为圆弧形了。
android edittext 圆角50%
要设置一个 `EditText` 的圆角为50%,可以通过定义一个圆形的背景来实现。以下是一个示例代码:
1. 在 `res/drawable` 目录下创建一个名为 `edittext_rounded_corner.xml` 的文件,代码如下:
```xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="50%" />
<solid android:color="@android:color/white" />
<stroke
android:width="1dp"
android:color="@android:color/darker_gray" />
</shape>
```
2. 在布局文件中使用定义的背景:
```xml
<EditText
android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edittext_rounded_corner" />
```
这样,你就可以得到一个圆角为50%的 `EditText`。
相关推荐
![](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)