Android应用栏在灵活空间中滚动重叠内容

时间:2018-04-16 09:00:02

标签: android android-collapsingtoolbarlayout android-nestedscrollview

在我的布局中,使用应用栏滚动,在灵活空间中重叠内容

我在嵌套滚动视图中的水平滚动视图中有一个按钮列表,我想在滚动时停止顶部(操作栏下方)的水平滚动按钮布局。如何实现这一点,请帮忙?

这是我的布局结构:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:ignore="RtlHardcoded">

    <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:id="@+id/collapsing"
            android:layout_width="match_parent"
            android:layout_height="200dp"
            app:contentScrim="?colorPrimary"
            app:expandedTitleMarginBottom="94dp"
            app:expandedTitleTextAppearance="@style/CollapsingTextAppearance.Inverse"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            app:title="@string/app_name">

            // conatins my header view

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

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/swipeLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:behavior_overlapTop="38dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <android.support.v4.widget.NestedScrollView
            android:id="@+id/nestedScrollView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="none">

            <android.support.v7.widget.CardView
                android:id="@+id/cardview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="@dimen/margin"
                app:cardBackgroundColor="@color/white"
                android:focusableInTouchMode="false"
                android:focusable="false"
                app:cardCornerRadius="10dp"
                app:cardElevation="4dp"
                app:contentPaddingBottom="16dp"
                app:contentPaddingLeft="0dp"
                app:contentPaddingRight="0dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">

                    <HorizontalScrollView
                        android:id="@+id/horizontalSV"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:fillViewport="true"
                        android:scrollbarSize="2dp">

                        .... // conatins buttons

                        .... // conatins my list view view

                        </HorizontalScrollView>

                    </LinearLayout>


                </android.support.v7.widget.CardView>
        </android.support.v4.widget.NestedScrollView>
    </android.support.v4.widget.SwipeRefreshLayout>
    </android.support.design.widget.CoordinatorLayout>

参见随附的参考资料截图

enter image description here

1 个答案:

答案 0 :(得分:1)

将您的代码更改为this.cut您的代码并在cardview中使用滚动行为

as.data.frame(gsub("[[:punct:]]", "", as.matrix(df)))