布局文件中加入background属性:

        <EditText
            android:layout_width="200dp"
            android:layout_height="wrap_content"
            android:inputType="phone"
            android:text=""
            android:id="@android:id/edit"
            android:background="@drawable/edit_bg"/>

然后在drawable文件夹下新建一个名为edit_bg的xml,里面内容为:

<?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:shape="rectangle">
            <solid
                android:color="#EFEFEF"/>
            <corners
                android:radius="3dip"
                />
            <stroke
                android:width="0.5px"
                android:color="#505050"/>
        </shape>
    </item>
</layer-list>

给EditText设置边框

 

相关文章:

  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2021-10-19
  • 2022-02-17
  • 2021-07-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案