自定义带边框的编辑文本 [英] Custom edit text with borders
本文介绍了自定义带边框的编辑文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在编辑文本上加边框,并在其上贴上标签.我已经像这样划定了边界:
I am trying to put borders on edit text and put a label on it. I have made the border like this :
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="1dp"
android:color="#A0A0A0" />
</shape>
但是我无法达到我想要的结果.
but I am not able to achieve my desired result.
我想要类似下面的内容:
I want something like below :
请帮助.
推荐答案
尝试一下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="15dp"
android:background="@drawable/boarder"
android:paddingLeft="5dp"
android:text="input" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="7dp"
android:background="#ffffff"
android:text="Label" />
</RelativeLayout>
boarder.xml:
boarder.xml :
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<stroke
android:width="2dp"
android:color="#03A6F0" />
<corners android:radius="12dp" />
这篇关于自定义带边框的编辑文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文