Answer the question
In order to leave comments, you need to log in
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?
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question