Implementation of Android custom view expansion menu function

First show you the effect picture. If you feel good, please refer to the implementation code.

thinking

1. Add a FrameLayout to the parent view of the button in the lower corner, that is, the transparent gray part of the full screen in the figure.

Set invisible when the menu does not pop up.

Set the FrameLayout click event and retract the menu when clicking.

Corresponding init ()

2. Add menu buttons in the ramelayout, that is, the three pop-up buttons.

Set invisible when the menu does not pop up.

Corresponds to addelement() and freshelement()

3. Click the button in the lower right corner to rotate the icon (or not).

Corresponding to setrotateanimation()

4. Adjust the transparency of the fragment from 0 to 1

Corresponding changebackgroudstatus()

5. The single button is set to be visible and pops up around

Corresponding settranslation ()

Click me to view the source code

usage method:

In the XML file, the parent class is floatingactionbutton:

In activity:

After the pop-up menu, the background color is determined by yourself. You need to declare a color in colors.xml:

Name must be 'background'

The above is the implementation of Android custom view expansion menu function introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

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