我正在使用协调器布局、回收器 View 和 float 按钮。不知何故,fab 按钮不会停留在布局的底部。我希望按钮即使在滚动时也能留在底部。我所知道的是,fab 按钮位于回收站 View 中最后一项的底部位置。
list-activity.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
tools:listitem="@layout/activity_sample_05borangb_parent"
android:id="@+id/recyclerView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foregroundGravity="bottom"
android:layout_gravity="bottom|end"/>
</android.support.design.widget.CoordinatorLayout>
最佳答案
试试这个:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foregroundGravity="bottom"
android:layout_margin="16dp"
android:layout_gravity="bottom|end"/>
</android.support.design.widget.CoordinatorLayout>
关于android - 如何让 float 按钮停留在布局底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46065354/