CollapsingToolbarLayout | Scrolling and layout issues
I want to use 2 different fragments that will allow me to chan
Add android:fitsSystemWindows="true"
to your AppBarLayout
, CollapsingToolbarLayout
, and to your ImageView
.
I'm guessing a part of your image is below the status bar (due to these lines being missing) which is why you can't see the top of the image.
collapseMode="pin"
only affects how the Toolbar reacts to collapsing (hence why it is called collapseMode
and not scrollFlags
).
In almost all cases when using CollapsingToolbarLayout
, you should be using scroll|exitUntilCollapsed
for your scrollFlags
- this keeps the collapsed Toolbar visible even when you scroll downward.
This is due to using scroll|enterAlways
. Change your flags as per #2
As mentioned in the answer to your related question, you need to call getSupportActionBar().setDisplayHomeAsUpEnabled(true);
to show the Up button:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
final Toolbar toolbar = (Toolbar) findViewById(R.id.anim_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
CollapsingToolbarLayout collapsingToolbar =
(CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbar.setTitle("Avengers: Age of Ultron");
}
Remove app:contentScrim="?attr/colorPrimary"
from your layout XML in CollapsingToolBarLayout
tag. It will show the back button in toolbar