In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the "Android how to achieve custom View expansion menu function" related knowledge, in the actual case of the operation process, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!
Effect picture
Train of thought
1. The parent View of the lower corner Button adds a FrameLayout, that is, the transparent gray part of the full screen.
Set to invisible when the menu does not pop up.
Set the FrameLayout click event and retract the menu when clicked.
Corresponding to init ()
Add menu buttons to 2.rameLayout, the three pop-up buttons.
Set to invisible when the menu does not pop up.
Corresponding to addElement () and freshElement ()
3. The button in the lower right corner, rotate the icon (or not).
Corresponding to setRotateAnimation ()
4. Sex animation changes the transparency of fragment from 0 to 1
Corresponding to changeBackgroudStatus ()
5. The single button is made visible and pops around
Corresponding to setTranslation ()
Click on me to check the source code
How to use it:
In the XML file, the parent class is FloatingActionButton:
In Activity:
UnfoldButton f = (UnfoldButton) findViewById (R.id.unfoldButton); f.addElement (R.drawable.bestjay, new View.OnClickListener () {@ Override public void onClick (View v) {/ / Click events} of the menu written here}); f.addElement (R.drawable.bestjayjay null); / / ditto f.addElement (R.drawable.bestjayjay null); / / Ibid f.setmRotatable (true) / / sets whether the icon is rotated by default to true f.setmScale (1); / / sets the scale of the pop-up scale 1 to the non-scaling range: 0-1 f.setLength (250); / / sets the pop-up distance
After the pop-up menu, the background color is up to you. You need to declare a color in colors.xml:
# 9b414141
Name must be "background"
This is the end of the content of "how to implement the custom View deployment menu function by Android". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.