简体   繁体   中英

toolbar turns to blank while scrolling the view

am using coordinator layout for hiding the toolbar but the problem is in some devices (android 4.4)am getting blank toolbar while scrolling the list ,please help me

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"

        android:layout_height="?attr/actionBarSize">

        <android.support.v7.widget.Toolbar
            android:id="@+id/n_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:theme="@style/ToolbarColoredBackArrow"
            app:layout_scrollFlags="scroll|enterAlways"
            android:minHeight="?attr/actionBarSize">

            <ViewStub
                android:id="@+id/toolbar_view_stub"
                android:layout_width="match_parent"
                android:background="@color/primary"
                android:layout_height="match_parent" />
        </android.support.v7.widget.Toolbar>
    </android.support.design.widget.AppBarLayout>
    <!--add your layout content here -->


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <View
            style="@style/match_wrap"
            android:layout_height="0.5dp"
            android:background="@color/accent" />

        <ViewStub
            android:id="@+id/content_area"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />
    </LinearLayout>
    <android.support.design.widget.FloatingActionButton

        android:id="@+id/fab_refine"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="end|bottom"
        android:visibility="gone"
        android:layout_marginBottom="50dp"
        android:layout_marginRight="50dp"

        app:backgroundTint="@color/color_blue" />


</android.support.design.widget.CoordinatorLayout>

在此处输入图片说明

Try like this...

    <android.support.v7.widget.Toolbar 
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/primary"
        android:minHeight="?attr/actionBarSize"
        android:textAlignment="center"
        local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" >

     <ViewStub
                    android:id="@+id/toolbar_view_stub"
                    android:layout_width="match_parent"
                    android:background="@color/primary"
                    android:layout_height="match_parent" />
     </android.support.v7.widget.Toolbar>

May it help!

Found out the solution I have to add an empty view just below the toolbar

<android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:id="@+id/n_toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:minHeight="?attr/actionBarSize"
            app:theme="@style/ToolbarColoredBackArrow">

            <ProgressBar
                android:id="@+id/progressBar"
                style="@style/wrap_wrap"
                android:visibility="gone"
                android:layout_gravity="end"
                android:indeterminate="true"
                android:padding="@dimen/defaultLayoutPadding" />

            <ViewStub
                android:id="@+id/toolbar_view_stub"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </android.support.v7.widget.Toolbar>
        <!-- The empty is used for fixing the empty blank header issue,please don't remove it -->
        <View
            android:layout_width="fill_parent"
            android:layout_height="1dp" />
    </android.support.design.widget.AppBarLayout>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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