android - 如何创建如图所示的圆形编辑文本

标签 android android-layout android-edittext

enter image description here

谁能告诉我如何将编辑文本的上两个角设置为圆角(用户名),将电子邮件的下两个角设置为圆角。

最佳答案

您将需要两个 shape 可绘制文件。

对于顶部的 EditText,调用它,top_edittext_bg:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <solid
        android:color="#e2e2e2" >
    </solid>

    <corners
        android:radius="1dp"
        android:bottomLeftRadius="0.1dp"
        android:bottomRightRadius="0.1dp"
        android:topLeftRadius="5dp"
        android:topRightRadius="5dp" >
    </corners>

</shape>

对于底部的EditText,调用它例如bottom_edittext_bg:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <solid
        android:color="#e2e2e2" >
    </solid>

    <corners
        android:radius="1dp"
        android:bottomLeftRadius="5dp"
        android:bottomRightRadius="5dp"
        android:topLeftRadius="0.1dp"
        android:topRightRadius="0.1dp" >
    </corners>

</shape>

然后将 android:background="@drawable/RESPECTIVE_XMLS" 属性中的这些设置为相关的 EditText

关于android - 如何创建如图所示的圆形编辑文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14027832/

相关文章:

android - 如何使用 Moshi 序列化 SparseArray

android - 如何在应用启动器图标中显示通知计数

android - Android 中可以更改 Edittext、Radio Button 和 CheckBox 的字体类型吗

android - 防止在 EditText 上输入键,但仍将文本显示为多行

android - 应在之后检测到文本更改

android - 是否有任何标准的 android 属性指定文本的颜色为白色

android - 使用 Neural sdk for Android 进行身份验证后如何获取访问 token

android - 将 RecyclerView 和 Material Design 依赖项永久添加到 android studio 中的新项目

android - 为什么 getLocationOnScreen() 和 getLocationInWindow() 返回相同的值?

android - Admob AdView 导致 ScrollView 在显示时滚动