How does Android Customize button effects

Everyone can see how ugly the Android native buttons are and how monotonous the effect is. To make an app, you need to use buttons. A good-looking button needs good-looking effects and appearance. This time, I mainly tell you how to use drawable XML files to get some good-looking custom styles.

First, the appearance is square in the app. The buttons with black characters on a gray background are ugly. We want to see rounded corners, colors and white characters (other styles can also be used according to your personal aesthetics). First, create a new button in the layout, and then create a new drawable resource file in the drawable folder. You might as well name it shape, add a selector node, create an item node, and add styles in the item node

If you want to make the button style after clicking, you need to add an item node. This is the whole drawable

This style is generally bright green with rounded corners around it, and white rounded corners when clicking. There are many situations besides clicking. Please find them yourself when clicking, which is also similar

OK, next is the setting of the layout file

Set the text to white in the middle. Well, a nice button was born

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
分享
二维码
< <上一篇
下一篇>>