The FAB (floating action button) in Android realizes the gradient effect of sliding up and down

preface

Promoted actions refers to an action button, which is not placed in the actionbar, but directly in the visible UI layout (of course, the UI here refers to the scope governed by setcontentview). Therefore, it is easier to get it in the code (imagine if you want to get a menu button in the actionbar?). Promoted actions are often mainly used for the main operations of an interface. For example, in the email mailing list interface, promoted actions can be used to accept a new email. Promoted action is actually a floating button in appearance. More commonly, it is a circular button floating on the interface. Generally, I directly call promoted action a floating button, and its English name is float action button for short (Fab, not FBI).

The system's own Fab will also scroll up and down with the page, but the effect of fading out or entering is too unnatural.

Here is a small knowledge point. The animation effect of Fab gradually changes as the recyclerview of the page scrolls up and down.

The layout containing the Fab control is as follows:

The implemented java code is as follows:

fab_ The in.xml file is as follows (the same is true for fab_out.xml). Of course, to change the fade out or entry style, you can generally modify the XML file here:

The general effect is like the above.

summary

Well, that's all the content of this article. I hope the content of this article can bring some help to Android developers. If you have any questions, you can leave a message.

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