Text input box similar to WeChat, text input box similar

Source: Internet
Author: User

Similar text input box, similar to text input box

The content of this article is relatively simple. It shows you how to implement the text input box. In fact, it is just a special background for a common text box. You can decompile how to implement it. here we will introduce how to implement this background.

Let's take a look at the text box at the end of the article. Is the text box quite similar? Let's talk about the implementation idea below:

First, I don't know if this effect can be made using the. 9 diagram. If no. 9 graph is needed, it can only be written using drawable. This drawable is a bit complicated and can be implemented using LayerList. My thoughts are as follows:

It is implemented by three layers. Here we assume that the background of the activity is white, and the first layer (that is, the bottom layer) is green. The second is white, but there is a small offset from the bottom, the purpose is to make a small tick on both sides of the text box; the third layer is also white, but it is a certain distance from the bottom and left and right sides. Through three layers of cooperation, you can achieve this effect. Xml is as follows:

<?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:bottom="6dp">        <shape android:shape="rectangle" >            <solid android:color="#ffffff" />        </shape>    </item>    <item        android:bottom="1dp"        android:left="1dp"        android:right="1dp">        <shape android:shape="rectangle" >            <solid android:color="#ffffff" />        </shape>    </item></layer-list>
Then, set xml to the background of the text box. It should be noted that this method cannot be an xml drawable that can be used in different colors at the same time.


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.