Learning about EditText in android (15) and androidedittext

Source: Internet
Author: User

Learning about EditText in android (15) and androidedittext

EditText is very similar to TextVew. TextView is used to display text and does not input text. However, EditText can be used to input text. Next, let's look at the common attributes of EditText.

Effect 1:

<Span style = "font-size: 18px;"> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "match_parent" android: layout_height = "match_parent" android: background = "# ffffff" android: orientation = "vertical" android: gravity = "center"> <EditText android: id = "@ + id/TV _weixin" android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: layout_marginLeft = "8dp" android: layout_marginRight = "8dp" android: gravity = "center" android: hint = "Enter ID"/> </LinearLayout> </span>


Android: layout_width = "fill_parent": Fill the width of the parent container

Android: layout_height = "wrap_content": height Package content

Android: layout_marginLeft = "8dp": 8dp to the left
Android: layout_marginRight = "8dp": distance from the right side to 8dp

Android: gravity = "center": center content

We use android: hint to specify the prompt information of the text box.


Effect 2:

<span style="font-size:18px;"> <EditText        android:id="@+id/tv_weixin"        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_marginLeft="8dp"        android:layout_marginRight="8dp"        android:gravity="center"        android:inputType="numberPassword" /></span>


Android: inputType = "numberPassword" is used to specify the input password.

InputType can specify many parameters. For example, number indicates a number box, and data indicates the input date;


The following uses background to customize some dazzling Effects

1,

<span style="font-size:18px;"><EditText        android:id="@+id/tv_weixin"        android:layout_width="fill_parent"        android:layout_height="30dp"        android:layout_marginLeft="8dp"        android:layout_marginRight="8dp"        android:gravity="center"        android:background="@drawable/weixin3" /></span>
Weixin3 file:

<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" >    <solid android:color="#0000"/>    <stroke android:width="3dp"        android:color="#3f5"/></shape></span>
The effect is as follows: Set the background color to transparent, the border to green, and the width to 3dp

2. Set the above background property to the following file

<span style="font-size:18px;"><?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="#0ac39e" />        </shape>    </item>       <item android:left="2dp"        android:right="2dp"        android:bottom="2dp">        <shape android:shape="rectangle">            <solid android:color="#ffffff"/>        </shape>    </item>     <item android:bottom="6dp">        <shape android:shape="rectangle">            <solid android:color="#ffffff" />          </shape>    </item></layer-list></span>

The effect is as follows (this effect is through Ren yugang's blog (http://blog.csdn.net/singwhatiwanna/article/details/42215847 ))



3,

<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" >    <item>        <shape android:shape="oval" >            <solid android:color="#0ac39e" />        </shape>    </item>    <item android:top="6dp"        android:bottom="6dp">        <shape android:shape="rectangle" >            <solid android:color="#ffffff" />        </shape>    </item>    <item android:bottom="6dp"        android:top="6dp">        <shape android:shape="rectangle" >            <solid android:color="#ffffff" />        </shape>    </item>    <item android:left="2dp"        android:right="2dp"        android:top="2dp"        android:bottom="6dp">        <shape android:shape="rectangle">            <solid android:color="#ffffff"/>        </shape>    </item>     <item android:left="2dp"        android:right="2dp"        android:top="6dp"        android:bottom="2dp">        <shape android:shape="rectangle">            <solid android:color="#ffffff"/>        </shape>    </item></layer-list></span>
The effect is as follows:




Reprinted please indicate the source: http://blog.csdn.net/hai_qing_xu_kong/article/details/42584999 sentiment control _





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.