Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Floating Action Button expansion [closed]

Tags:

According to the new Android Design Guidelines for the Floating Action Button, it should be reasonable to transform the Floating Action Button into a Toolbar.

Are there any samples / examples to perform such a transformation?

like image 665
Knossos Avatar asked Apr 16 '15 15:04

Knossos


People also ask

What does a floating action button do?

A floating action button (FAB) is a circular button that triggers the primary action in your app's UI. This page shows you how to add the FAB to your layout, customize some of its appearance, and respond to button taps.

Are Floating buttons accessible?

The FloatingActionButton is accessible by screen readers and provides WAI-ARIA, Section 508, WCAG 2.1, and keyboard support. The Accessibility is part of Kendo UI for jQuery, a professional grade UI library with 110+ components for building modern and feature-rich applications.


2 Answers

To use reveal animation you need add a onLayoutChange listener to the view in onCreateView callback like this:

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        // Inflate the layout for this fragment
        final View view = inflater.inflate(R.layout.fragment_map_list, container, false);
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
                @TargetApi(Build.VERSION_CODES.LOLLIPOP)
                @Override
                public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
                    v.removeOnLayoutChangeListener(this);
                    revealView(view);
                }
            });
        }
        return view;
    }

where the revealView() method will be:

private void revealView(View view) {

    toolbar = view.findViewById(R.id.mytoolbar);

    int cx = (view.getLeft() + view.getRight()) / 2;
    int cy = (view.getTop() + view.getBottom()) / 2;
    float radius = Math.max(infoContainer.getWidth(), infoContainer.getHeight()) * 2.0f;

    if (infoContainer.getVisibility() == View.INVISIBLE) {
        infoContainer.setVisibility(View.VISIBLE);
        ViewAnimationUtils.createCircularReveal(infoContainer, cx, cy, 0, radius).start();
    } else {
        Animator reveal = ViewAnimationUtils.createCircularReveal(
                infoContainer, cx, cy, radius, 0);
        reveal.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                toolbar.setVisibility(View.INVISIBLE);
            }
        });
        reveal.start();
    }
}

In this way you should be able to create your animation. This is the way to use it. Just apply this at your fab onClick() method

like image 62
Atlas91 Avatar answered Sep 19 '22 22:09

Atlas91


Looks to me like a Circular Reveal Animation which uncovers a custom Toolbar.

like image 32
Quoting Eddie Avatar answered Sep 20 '22 22:09

Quoting Eddie