滚动后如何防止工具栏崩溃?

时间:2019-02-21 10:00:56

标签: android android-layout

enter image description here

enter image description here

滚动后,我不希望工具栏折叠,而只是ImageView,类似于exitUntillCollapsed。但是我希望应用程序栏在最小的向下滚动上扩展。我该如何实现?

for (i in 1:number_of_variables){
     variable=get(paste0("var",i))

     ... work on the variable ...
    # Returns
    assign(paste0("df_sub",i), ... your result ...)
}

1 个答案:

答案 0 :(得分:1)

对于滚动行为,请使用标志enterAlways

对于“修复”工具栏布局,请在您的coordinatorLayout上方添加工具栏布局。

<LinearLayout 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:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:layout_collapseMode="pin"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appBarLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsingToolbarLayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:contentScrim="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways">

                <ImageView
                    android:id="@+id/imageViewCollapsing"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="centerCrop"
                    android:src="@drawable/winterscenery"
                    app:layout_collapseMode="parallax" />


            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>


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

</LinearLayout>