在 NestedScrollview 中使用 RecyclerView 时出现奇怪的 space(间隙)
Showup strange space (gap) when use RecyclerView inside NestedScrollview
我正在尝试构建一个包含 RecyclerView
的 BottomSheet
。我使用了 NestedScrollView
并将其行为设置为 "bottom_sheet_behavior"。第一次应用 运行,它正常弹出,但是当我从微调器中折叠 BottomSheet
和 select 项目时,它弹出并在其下方显示 space .
这只发生在 android 8,而不是其他版本。
另一方面,当我删除 RecyclerView
时,它正常工作。
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.toptoche.searchablespinnerlibrary.SearchableSpinner
android:id="@+id/spinner"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginTop="200dp"
android:background="#c9c5c5"
android:elevation="8dp"
android:entries="@array/seasons"
android:layoutDirection="rtl"
android:spinnerMode="dialog"
android:textAlignment="center"
android:textDirection="rtl" />
</LinearLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="300dp"
android:fillViewport="true"
android:background="@color/colorPrimary"
android:elevation="6dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/activity_Recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
First run
After select an item from spinner
折腾了半天终于找到问题所在。那是因为使用了这个库 ==> Searchable Spinner 。我用简单的微调器替换了它,它工作正常!
Point:: Always use updated and supported libraries :|
我正在尝试构建一个包含 RecyclerView
的 BottomSheet
。我使用了 NestedScrollView
并将其行为设置为 "bottom_sheet_behavior"。第一次应用 运行,它正常弹出,但是当我从微调器中折叠 BottomSheet
和 select 项目时,它弹出并在其下方显示 space .
这只发生在 android 8,而不是其他版本。
另一方面,当我删除 RecyclerView
时,它正常工作。
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.toptoche.searchablespinnerlibrary.SearchableSpinner
android:id="@+id/spinner"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginTop="200dp"
android:background="#c9c5c5"
android:elevation="8dp"
android:entries="@array/seasons"
android:layoutDirection="rtl"
android:spinnerMode="dialog"
android:textAlignment="center"
android:textDirection="rtl" />
</LinearLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="300dp"
android:fillViewport="true"
android:background="@color/colorPrimary"
android:elevation="6dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/activity_Recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
First run
After select an item from spinner
折腾了半天终于找到问题所在。那是因为使用了这个库 ==> Searchable Spinner 。我用简单的微调器替换了它,它工作正常!
Point:: Always use updated and supported libraries :|