如何设置背景的Android到EDITTEXT? [英] How to set background to edittext in android?
本文介绍了如何设置背景的Android到EDITTEXT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用自定义绘制设置编辑text.Following的背景是$ C $下编辑文本背景
I am using custom drawable to set background of edit text.Following is the code for edit text background
<?xml version="1.0" encoding="utf-8"?>
<corners android:radius="1dp" />
<stroke
android:width="1dp"
android:color="#595C65" />
<solid android:color="#ffffff" />
它显示的矩形背景的编辑框。但我想设置编辑文本的背景与L形(设置左和底部的背景)。
It displays the edit box with rectangle background .But i want to set edit text background with L shape(set left and bottom backgrounds).
如果不使用外部图像,我希望通过绘制XMLS设置这些背景。
Without using external images and i want to set these background via drawable xmls.
期望的输出:
Expected output:
电流输出:
Current output:
推荐答案
我发现这些解决方案:
text.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape android:shape="rectangle">
<solid android:color="#000000" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="#000000" />
</shape>
</item>
<item android:bottom="3px" android:left="3px">
<shape android:shape="rectangle">
<solid android:color="#FFFFFF" />
</shape>
</item>
</layer-list>
main.xml中:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/editText1"
android:background="@drawable/text"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="30dp"
android:ems="10"
android:gravity="center_horizontal"
android:padding="2dp"
android:password="true" />
</RelativeLayout>
预计输出:
如果不使用外部图像,我们可以用绘制text.xml的帮助下,输出
Without using external images we can get a output with the help of drawable text.xml
这篇关于如何设置背景的Android到EDITTEXT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文