android - NestedScrollView 内容未显示在 CoordinatorLayout 中

标签 android android-design-library android-coordinatorlayout

我在 NestedScrollView 中有一些内容没有显示。唯一显示的是 AppBarLayout 的内容。但是,当我用包含 RecyclerView 的 fragment 替换 NestedScrollView 时,它会按预期显示。我似乎无法弄清楚我在这里做错了什么。

编辑:我刚刚测试过,如果我完全删除 AppBarLayout 以及 NestedScrollView< 上的 app:layout_behavior="@string/appbar_scrolling_view_behavior" 属性,Android Studio 中的预览 Pane 确实显示了我的滚动内容。

<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.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <!-- Extended toolbar -->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:minHeight="?attr/actionBarSize"
            app:layout_collapseMode="pin">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"/>

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:minHeight="72dp">

                <EditText
                    android:id="@+id/name"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textCapSentences|textMultiLine"
                    android:hint="Name"/>

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

        </LinearLayout>

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

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

<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

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

        <!-- Scrolling content here -->

    </LinearLayout>

</android.support.v4.widget.NestedScrollView>

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

最佳答案

尝试将以下行添加到您的 NestedScrollView:

android:fillViewport="true"

关于android - NestedScrollView 内容未显示在 CoordinatorLayout 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31110689/

相关文章:

android - 在 AlertDialog 之后调用新的 Intent

android - viewModelScope 未取消

android - 折叠工具栏折叠时隐藏 float 按钮

android - 使用 CoordinatorLayout、Swipe2Refresh 和 WebView 时布局顶部的工具栏

当将布局包含到协调 View 中时,android Studio 布局预览为空

Android更新textview计时器并刷新 map 内容?

java - Tablayout ,禁用滑动选项卡之间的更改

android - BottomNavigationView 与 RecyclerView 垂直滚动的垂直滚动 CoordinatorLayout 行为

android - Bottomsheet 总是隐藏我最后的 Recyclerview 元素

android - 在协调器布局中隐藏工具栏下方的 View