【发布时间】:2018-09-07 21:40:58
【问题描述】:
我有这个布局:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
...
<FrameLayout
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="200dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</android.support.constraint.ConstraintLayout >
这个recyclerview被添加到“id/content”框架布局中
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:layout_gravity="bottom"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
app:layoutManager="LinearLayoutManager" />
recyclerview 放在屏幕底部,效果理想。
当recyclerview中有很多viewholder时,问题就出现了。我想在顶部留出一些空间以仍然看到地图(200dp 边距)。我尝试了很多方法,似乎无法找到一个优雅的解决方案。基本上我想要的是 recyclerview 将 wrap_content 直到内容太大。如果内容太大,我希望 recyclerview 扩展以填充它可以填充的空间,同时在顶部保留 200dp。在 iOS 中,这可以使用 >= 200 约束。这在安卓上可行吗?怎么样?
【问题讨论】:
-
那么地图View在FrameLayout之外?而且 200dp 的边距不起作用?
-
看看
BottomSheetBehavior,看看它是否能满足您的需求。
标签: android android-layout android-recyclerview android-constraintlayout