How to put a border in an EditText? [duplicate]

拥有回忆 提交于 2019-12-13 23:04:11

问题


anybody could tell me, how to put a border in an editText in AndroidStudio?

for example a square in an editText.


回答1:


just try this one,

first create one XML file, inside drawable folder (use new drawable xml) and add this lines

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"/>      
<solid android:color="#000000"/>
<stroke
    android:color="#ffffff"
    android:width="05dp"/>
<corners android:radius="20dp"/>

then add this line inside Your edittext property

android:background="@drawable/(file_name)"

i don't know what your expecting, maybe it will help you




回答2:


It's so easy bro

First step create an shape.xml in your directory drawable

<?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>

Second step create your editext in your layout.xml and put background with the shape that you created above

<EditText
    android:id="@+id/edittext"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/shape"/>

It's all



来源:https://stackoverflow.com/questions/48083236/how-to-put-a-border-in-an-edittext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!