Try to override this acording to your need. You can set layouts making visible/hide components in CollapsableToolbar.
appbar = (AppBarLayout) findViewById(R.id.appbar);
header = (Toolbar) findViewById(R.id.toolbar);
appbar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
private State state;
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
if (verticalOffset == 0) {
if (state != State.EXPANDED) {
collapsingToolbar.setTitleEnabled(false);
// do something here
}
state = State.EXPANDED;
} else if (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) {
if (state != State.COLLAPSED) {
collapsingToolbar.setTitle("All Jobs ");
collapsingToolbar.setTitleEnabled(true);
// do something here header.setBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.actionbar_gradient));
// collapsingToolbar.setContentScrim(ContextCompat.getDrawable(this, R.drawable.actionbar_gradient));
collapsingToolbar.setContentScrim(ContextCompat.getDrawable(this, R.drawable.actionbar_bg));
// collapsingToolbar.setBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.actionbar_bg));
}
state = State.COLLAPSED;
} else {
if (state == State.IDLE) {
collapsingToolbar.setTitleEnabled(false);
container.setVisibility(View.VISIBLE);
}
state = State.IDLE;
}
}
});
It worked for me try it....