Design of input box EditText for Android advanced XML layout

Today, I'd like to introduce how to realize a simple and fashionable Android login interface. Let's take a look at the renderings first

When the user enters, the delete button appears dynamically

Now let's list the technical points: 1. How to use the rounded input box and button background 2. How to realize the vertical line behind "mobile phone number" and "password" 3. How to nest the layout of the input box 4. How to monitor the input events of the input box and delete the dynamic display and hiding of the button

1. How to use rounded input boxes and button backgrounds

Android has prepared the XML tag shape for developers to customize some shapes. Then I'll define a white input box background. The code is as follows:

Set it to the background of any view

2. How to realize the vertical line behind "mobile phone number" and "password"

This is actually very simple. Just write a vertical line with a width of 1DP or 1px (or a value you think is more appropriate).

3. How to nest the layout of input boxes

Android provides us with a variety of layouts, but you can't design the interface with any one. Must be nested. Many novices dare not nest. We must be bold to nest and use various layouts. We will combine cool effects. The layout here is very simple, just a layer of nesting (the whole page layout nested the layout of the input box).

4. How to listen to the input events of the input box and the dynamic display and hiding of the delete button

The idea is very simple. It is to listen to the input event of EditText. Then, if the input length is greater than 0, the subsequent delete button will be displayed. If = 0, the delete button will be hidden. Click the delete button to clear the input box. Here I write a tool class for you to call. High cohesion and low coupling are our common pursuit.

Main program code

The importance of XML to Android programs is believed that we will gradually realize it in the development process. Here is just a simple example. Many good Android technology blogs will be updated later. I'm an zhuotan. Thank you for your support. I hope you can communicate more.

Code connection: source code download

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>