The CollapsingToolbarView works perfectly fine, but there is this unwanted strip on the ImageView of the collapsing toolbar.
As you can see below there is a red strip (possibly toolbar) after the status bar. How do I get rid of it?
Below is the relevant xml file:
fragment_movie.xml
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
tools:context="com.jayeshsolanki.mmdb.ui.fragment.MovieFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview_movie"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimaryDark"
app:title="@string/placeholder_movie_item_title">
<ImageView
android:id="@+id/backdrop_movie"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
app:layout_collapseMode="parallax"
tools:src="@drawable/placeholder_movie_item_backdrop"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_movie"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>
The theme for the parent activity is set as "@style/AppTheme.NoActionBar"
in the Manifest.
android:fitsSystemWindows="true"
is supposed to be on CoordinatorLayout
, AppBarLayout
, CollapsingToolbarLayout
and the ImageView
inside it.
Try removing adjustViewBounds attribute from image. You're using centerCrop which should be enough for image to show properly and fill all space. By adjusting view bounds you're preserving aspect ratio, so the image doesn't fill the app bar space.
来源:https://stackoverflow.com/questions/37098519/when-not-collapsed-some-part-of-the-the-toolbar-is-visible-over-the-imageview-of