繁体   English   中英

未折叠时,工具栏的某些部分在CollapsingToolbarLayout的ImageView上可见

[英]When not collapsed some part of the the toolbar is visible over the ImageView of CollapsingToolbarLayout

CollapsingToolbarView工作得很好,但在折叠工具栏的ImageView上有这个不需要的条带。

如下所示,状态栏后面有一个红色条带(可能是工具栏)。 我怎么摆脱它?

screenshot1 screenshot2

以下是相关的xml文件:

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>

父活动的主题在Manifest中设置为"@style/AppTheme.NoActionBar"

android:fitsSystemWindows="true"应该在CoordinatorLayoutAppBarLayoutCollapsingToolbarLayout和它内部的ImageView

尝试从图像中删除adjustViewBounds属性。 您正在使用centerCrop,它应足以使图像正确显示并填充所有空间。 通过调整视图边界,您可以保留纵横比,因此图像不会填充应用栏空间。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM