【发布时间】:2017-08-14 08:25:42
【问题描述】:
如何在 android 的底部工作表和浮动操作按钮之间添加边距。我通过使用另一个 FAB 并使其不可见来使其工作,但 FAB 仅位于底部表上方。看这张图:1
还有代码:
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:theme="@style/Theme.AppCompat.NoActionBar"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout
android:id="@+id/search_relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:theme="@style/Theme.AppCompat.NoActionBar">
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/bottom_sheet"
android:layout_width="match_parent"
android:layout_height="300dp"
android:background="@android:color/white"
android:elevation="1dp"
app:behavior_hideable="true"
app:behavior_peekHeight="0dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/circle_picture"
android:src="@mipmap/login_background"
android:layout_margin="10dp"
android:layout_width="50dp"
android:layout_height="50dp" />
<TextView
android:id="@+id/name_bottom_sheet"
android:layout_toEndOf="@id/circle_picture"
android:text="Title"
android:textColor="@color/buttonLoginColor"
android:layout_margin="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/address_bottom_sheet"
android:layout_below="@id/name_bottom_sheet"
android:layout_toEndOf="@id/circle_picture"
android:layout_marginStart="10dp"
android:textColor="@color/btn_create"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="invisible"
android:layout_margin="15dp"
app:layout_anchor="@id/bottom_sheet"
app:layout_anchorGravity="top|end"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/floatingButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginEnd="15dp"
app:backgroundTint="@color/buttonLoginColor"
app:borderWidth="0dp"
app:elevation="6dp"
app:layout_anchor="@id/fab2"
app:layout_anchorGravity="top"/>
</android.support.design.widget.CoordinatorLayout>
我正在使用 NestedScrollView 来显示底部工作表。
【问题讨论】:
-
您能否显示此布局的完整 XML 以帮助您更好地理解?一些如何通过相对或坐标布局来实现这一点
-
我正在使用协调器布局是的。我编辑了我的问题。
-
是的,RelativeLayout 会起作用,你可以试试看,如果你觉得它有用,别忘了把它标记为 true,谢谢。
标签: android margin floating-action-button bottom-sheet