NestedScrollView未在CoordinatorLayout内部滚动-Android
以下布局中的嵌套滚动视图未滚动。如果我删除协调器布局,滚动将起作用。但是,我想保留协调器布局,将fab按钮放在我的卡片视图的底部NestedScrollView未在CoordinatorLayout内部滚动-Android,android,android-layout,android-coordinatorlayout,android-appbarlayout,android-nestedscrollview,Android,Android Layout,Android Coordinatorlayout,Android Appbarlayout,Android Nestedscrollview,以下布局中的嵌套滚动视图未滚动。如果我删除协调器布局,滚动将起作用。但是,我想保留协调器布局,将fab按钮放在我的卡片视图的底部 <?xml version="1.0" encoding="utf-8"?> <androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schema
<?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>
请分享你的想法。我被卡住了一段时间。只需将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>
只需将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>
它最终应该是什么样子?预期的输出是什么?您的NestedScrollView
应该在AppBarLayout
之外。顺便说一句,我并不是说AppBarLayout
将位于公认答案中发布的NestedScrollView
中。出于某种原因,它起了作用,但文档说,它们应该是布局层次结构中的兄弟布局。最终应该是什么样子?预期的输出是什么?您的NestedScrollView
应该在AppBarLayout
之外。顺便说一句,我并不是说AppBarLayout
将位于公认答案中发布的NestedScrollView
中。出于某种原因,它起作用了,但是文档说它们应该是布局层次结构中的同级布局,不需要用scrollview替换嵌套的scrollview。将应用程序栏布局放在嵌套的scrollview中就成功了。如果您编辑并提交答案,我将接受您的答案。无需将嵌套的scrollview替换为scrollview。将应用程序栏布局放在嵌套的scrollview中就成功了。如果您编辑并提交答案,我将接受您的答案。