D
D
Dmitry Richter2016-03-02 19:55:50
Android
Dmitry Richter, 2016-03-02 19:55:50

Can't find an animation example?

Then I decided to learn something new in android and remembered a cool thing on the playmarket, when you open the page, instead of the status bar, the picture, and after you go down and rise again, the status bar appears. I can not find a lesson on how to do something similar, who can help?6916b1045368499194f2401baaebbad1.png25af945c1b204d0c93c8c2a00a286d0b.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Dorofeev, 2016-03-02
@followthemoney

This effect is called Collapsing Toolbar with Parallax.
First we make a normal AppBarLayout with Collapsing Toolbar .
(You can customize the view for yourself)
Then we write code to check the view toolbar, in which we do what we need:

appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
            @Override
            public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
                if (isCollapsed(verticalOffset)) {
                    //set status bar color your color
                } else {
                    // set status bar color transparent
                }

            }
        });

    private boolean isCollapsed(int offset) {
        return offset == 0 || offset <= toolbar.getHeight();
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question