How to set the rounded corner button?
Why? Do you think Google's official buttons are ugly? Haha ~~ Here we provide some ideas on how to set the rounded corner for the button:
In Android, setting the background for a control (or View) is mainly done through the background: xxx attribute. The background parameter is generally a drawable resource. Drawable can be a normal image, a 9 patch image, or an xml file.
Method 1: Image
The easiest way to configure borders for a widget is to set the background as a background image with rounded corners and borders that you designed in advance.
However, you will soon find a drawback: poor flexibility! Yes, it is difficult to resize a fixed-size Image Based on the content in the control. It was confirmed on the day it was made! In other words, it is difficult for you to use only this image to deal with controls of the same style but different sizes. To add rounded corners and borders to all controls, you must carefully calculate their sizes and create background images one by one! Oh, that's silly. Once a variable-Size Control is encountered, this method will stop. In addition, a large number of background images will quickly expand your installation package. Er ...... Also, how do you deal with Android devices with various resolutions?
So, you need ...... Change the method.
The solution adopted by zookeeper is NinePatch. It is no exaggeration to say that patch 9 is a powerful tool in Android to solve adaptive problems.
Zookeeper has many advantages in using 9 patch images, such as reducing the stress on the artist, reducing the amount of UI code, and reducing memory usage ...... To sum up, it is time-saving and effort-saving.
Zookeeper, of course, 9 patch can do much more than this, such as making an adaptive dialog box or something. The end of a general 9patchimage is .9.jpg.