简体   繁体   English

NestedScrollView 不在 CoordinatorLayout 内滚动 - Android

[英]NestedScrollView not scrolling inside CoordinatorLayout - Android

The nested scroll view in the following layout is not scrolling.以下布局中的嵌套滚动视图不滚动。 The scrolling work if I remove the coordinator layout.如果我删除协调器布局,滚动工作。 But, I want to keep the coordinator layout to place the fab button on the bottom of my card view.但是,我想保留协调器布局以将 fab 按钮放在卡片视图的底部。

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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">

<com.google.android.material.appbar.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/bg_yellow_color">

    <androidx.cardview.widget.CardView
        android:id="@+id/content_card"
        style="@style/card_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.375">

            <androidx.core.widget.NestedScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="fill_vertical"
                android:fillViewport="true">

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

                    <TextView
                        android:id="@+id/tv_title"
                        style="@style/form_title"
                        android:text="@string/title" />

                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/name"
                        style="@style/form_input_layout"
                        android:layout_marginTop="@dimen/margin_40dp"
                        android:hint="@string/vendor_name">

                        <com.google.android.material.textfield.TextInputEditText
                            style="@style/form_input_field"
                            android:inputType="textPersonName"
                            android:maxLines="1" />
                    </com.google.android.material.textfield.TextInputLayout>

                   <!--a lot of other input fields here-->

                </LinearLayout>
            </androidx.core.widget.NestedScrollView>
    </androidx.cardview.widget.CardView>
</com.google.android.material.appbar.AppBarLayout>

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/fab_next"
    style="@style/fab_next"
    app:layout_anchor="@id/content_card" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

Please share your thoughts on this.请分享您对此的看法。 I have been stuck for a while.我被困了一段时间。

Just put AppBarLayout inside of the NestedScrollView... Like this只需将 AppBarLayout 放在 NestedScrollView 内...就像这样

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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">


        <androidx.core.widget.NestedScrollView 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <com.google.android.material.appbar.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/bg_yellow_color">

            <androidx.cardview.widget.CardView
                android:id="@+id/content_card"
                style="@style/card_content"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.375">


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

                    <TextView
                        android:id="@+id/tv_title"
                        style="@style/form_title"
                        android:text="@string/title" />

                    <com.google.android.material.textfield.TextInputLayout
                        android:id="@+id/name"
                        style="@style/form_input_layout"
                        android:layout_marginTop="@dimen/margin_40dp"
                        android:hint="@string/vendor_name">

                        <com.google.android.material.textfield.TextInputEditText
                            style="@style/form_input_field"
                            android:inputType="textPersonName"
                            android:maxLines="1" />
                    </com.google.android.material.textfield.TextInputLayout>

                    <!--a lot of other input fields here-->

                </LinearLayout>

            </androidx.cardview.widget.CardView>
        </com.google.android.material.appbar.AppBarLayout>
    </androidx.core.widget.NestedScrollView>

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/fab_next"
        style="@style/fab_next"
        app:layout_anchor="@id/content_card" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Kotlin NestedScrollView无法在CoordinatorLayout中滚动整个内容 - Android kotlin NestedScrollView not scrolling whole content inside CoordinatorLayout 突然在CoordinatorLayout Android内的ViewPager Fragment中使用NestedScrollView滚动 - Abrupt scrolling with NestedScrollView in ViewPager Fragment inside a CoordinatorLayout Android NestedScrollView不与CoordinatorLayout一起滚动 - NestedScrollView not scrolling with CoordinatorLayout 滚动时CoordinatorLayout内部的NestedScrollView的波浪效果不起作用 - Wave effect of NestedScrollView inside CoordinatorLayout is not working when scrolling 在CoordinatorLayout中自动滚动NestedScrollView无效 - Automatically scrolling of NestedScrollView inside CoordinatorLayout doesn't work NestedScrollView没有显示在CoordinatorLayout内部 - NestedScrollView not showing inside CoordinatorLayout ListView 不在 Android 中的 NestedScrollView 内滚动 - ListView is not scrolling inside NestedScrollView in android CoordinatorLayout与NestedScrollView和Horizo​​ntal Scrolling RecyclerView - CoordinatorLayout with NestedScrollView and Horizontal Scrolling RecyclerView NestedScrollView和CoordinatorLayout。 滚动问题 - NestedScrollView and CoordinatorLayout. Issue on Scrolling NestedScrollview中的NestedScrollView不滚动 - NestedScrollView inside NestedScrollview not scrolling
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM