【发布时间】:2015-12-17 09:44:06
【问题描述】:
我的布局文件中有 3 个视图,其中 CoordinatorLayout 作为根视图:AppbarLayout、RecyclerView 和页脚(始终不可见)。 Recyclerview 实现了默认行为 appbar_scrolling_view_behavior,理想情况下,将 recyclerview 置于 appbarlayout 之下。但是recyclerview和页脚重叠。为了防止这种情况,我必须编写一个自定义行为,以便当页脚可见时,Recyclerview 应该为页脚腾出空间。但是现在,appbar_scrolling_view_behavior 的默认行为消失了,现在 appbarlayout 和 recyclerview 重叠了。Here is the Image of the layout
链接到我实现的自定义行为: https://github.com/Mandeep221/CustomBehaviorForRecyclerview/blob/master/CustomBehavior.java
我的问题:我怎样才能实现两件事(同时在一个行为中):
- 在 co-ordinatorlayout 内的 appbarlayout 下方获取 recyclerview
- 如果页脚可见,请获取 recyclerview 为页脚腾出空间。
如果您能提出一些解决方法,那就太好了!非常感谢!
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways|snap" />
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/list_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="4dp"
android:scrollbars="vertical"
app:layout_behavior="prokure.it.prokure.Search.NewSearch.CustomBehavior" />
<prokure.it.prokure.FooterBarLayout
android:id="@+id/footerBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
//footer child views
</LinearLayout>
</prokure.it.prokure.FooterBarLayout>
</android.support.design.widget.CoordinatorLayout>
【问题讨论】:
标签: android android-recyclerview android-coordinatorlayout android-appbarlayout