我有一个问题,我试图将一个按钮和一个 recyclerview 添加到一个线性布局,该线性布局包含在一个 coordinatorlayout 中。我遇到的问题是,当我将滚动行为应用于 linearLayout 时,按钮会向上和向下滚动,与操作栏的作用相反。当我将滚动行为应用到 recyclerview 和按钮时,我的 recycler 视图的顶部隐藏在操作栏后面。
这是我的布局的样子:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
android:theme="@style/Theme.AppCompat.NoActionBar"
app:popupTheme="@style/Theme.AppCompat.NoActionBar">
<android.support.v7.widget.SearchView
android:id="@+id/recommender_search_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/Theme.AppCompat.NoActionBar"
app:popupTheme="@style/Theme.AppCompat.NoActionBar"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/contacts_recycler_view"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:background="@color/recommender_divider"/>
<Button
style="@style/GrapeFullscreenButtonPrimary"
android:id="@+id/send_button"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="Send (0)"/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
我已经搞砸了 fitSystemWindow 属性,但没有运气,并且还尝试了前面提到的多种场景的滚动行为。我一直在与这个问题作斗争一段时间,任何帮助将不胜感激。