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.