如何在 EditText 中添加边框?

O.S*_*hez -3 android android-layout android-edittext

有人可以告诉我,如何在 AndroidStudio 中的 editText 中添加边框吗?

例如 editText 中的正方形。

Abn*_*cio 5

太简单了兄弟

第一步在你的drawable目录中创建一个shape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke 
    android:width="1dp"
    android:color="@android:color/black"/>
</shape>
Run Code Online (Sandbox Code Playgroud)

第二步在layout.xml中创建编辑文本,并使用上面创建的形状放置背景

<EditText
    android:id="@+id/edittext"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/shape"/>
Run Code Online (Sandbox Code Playgroud)

就这样了