How to customize the button and set different background pictures for Android

This article describes the method of customizing buttons and setting different background pictures for Android. Share with you for your reference, as follows:

1. Custom MyButton class

2. Add a MyButton control to the XML layout file, just like applying a normal button control.

Where com.mybutton is the package name of the MyButton class you defined

3. Load the MyButton control in oncreate().

BTN_ D represents the background picture when BTN is pressed, BTN_ U is the BTN background picture in the default state

For more information about Android controls, readers who are interested can see the site's special topic: Android controls Usage Summary

I hope this article will help you in Android programming.

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