简体   繁体   中英

NestedScrollView content not displaying inside CoordinatorLayout

I have some content inside of a NestedScrollView that is not showing up. The only things that do display are the contents of the AppBarLayout . However, when I replace the NestedScrollView with a fragment containing a RecyclerView , it displays as expected. I can't seem to figure out what I'm doing wrong here.

EDIT: I just tested that if I remove the AppBarLayout entirely and also the app:layout_behavior="@string/appbar_scrolling_view_behavior" property on the NestedScrollView , the Preview pane in Android Studio does display my scrolling content.

<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"

You can use compile 'com.android.support:design:22.2.1'

Update to v22.2.1, this is fixed.

https://code.google.com/p/android/issues/detail?id=180811

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