【问题标题】:Nested scroll view goes behind collapsing toolbar in support design嵌套滚动视图位于支持设计中的折叠工具栏后面
【发布时间】:2015-12-22 05:51:11
【问题描述】:

这是NestedScrollView 里面的CoordinatorLayout

<?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"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:fitsSystemWindows="true"
    tools:context=".fests.ActFestivalDetail">


    <android.support.design.widget.AppBarLayout
        android:id="@+id/app_bar_parent"
        android:layout_height="@dimen/d_192"
        android:layout_width="match_parent"
        android:fitsSystemWindows="true"
        android:orientation="vertical">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/app_bar_collapse"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:expandedTitleMarginBottom="@dimen/d_32"
            app:expandedTitleMarginEnd="@dimen/d_64"
            app:expandedTitleMarginStart="@dimen/d_48"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            >
            <ImageView
                android:id="@+id/header"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="center"
                android:fitsSystemWindows="true"
                app:layout_collapseMode="parallax"/>
            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_height="@dimen/d_192"
                android:layout_width="match_parent"
                android:fitsSystemWindows="true"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                app:layout_collapseMode="pin"/>

        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>
    <android.support.v4.widget.NestedScrollView
        android:id="@+id/nested_scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        app:behavior_overlapTop="@dimen/d_64"
        >
        <include layout="@layout/detail_card"/>
    </android.support.v4.widget.NestedScrollView>

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

每当我尝试向上滚动它时,它都会运行良好,直到它移到工具栏后面。 有什么建议吗?

【问题讨论】:

    标签: android-coordinatorlayout nestedscrollview


    【解决方案1】:

    我认为你错过了一些基本的 android XML 技术。

    简单的答案是线性布局

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    
        <android.support.design.widget.AppBarLayout
            android:id="@+id/app_bar_parent"
            android:layout_width="match_parent"
            android:layout_height="@dimen/d_192"
            android:fitsSystemWindows="true"
            android:orientation="vertical">
    
            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/app_bar_collapse"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:expandedTitleMarginBottom="@dimen/d_32"
                app:expandedTitleMarginEnd="@dimen/d_64"
                app:expandedTitleMarginStart="@dimen/d_48"
                app:layout_scrollFlags="scroll|exitUntilCollapsed">
    
                <ImageView
                    android:id="@+id/header"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fitsSystemWindows="true"
                    android:scaleType="center"
                    app:layout_collapseMode="parallax" />
    
                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/d_192"
                    android:fitsSystemWindows="true"
                    app:layout_collapseMode="pin"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
    
            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>
    
        <android.support.v4.widget.NestedScrollView
            android:id="@+id/nested_scroll"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:behavior_overlapTop="@dimen/d_64"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">
    
            <include layout="@layout/detail_card" />
        </android.support.v4.widget.NestedScrollView>
    </LinearLayout>
    

    这可能有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-19
      • 1970-01-01
      • 1970-01-01
      • 2017-09-27
      • 2015-09-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多