如何在两个小部件/布局之间添加新的“浮动操作按钮”我想你已经看到了新的Android设计指南,新的“浮动动作按钮”,也就是“Fab”。我的问题听起来很愚蠢,而且我已经尝试了很多东西,但是在两个布局的交集处放置这个按钮的最好方法是什么呢?在上面的例子中,这个按钮被完美地放置在我们可以想象的图像视图和相对Layout之间。我已经尝试了很多调整,但我相信有一个正确的方法。
3 回答

缥缈止盈
TA贡献2041条经验 获得超4个赞
使用RelativeLayout 将两个相邻视图放置在另一个下面。 将Fab对齐到父的右/端,并添加一个右/尾边距。 将Fab对齐到标头视图的底部,并添加 负
保证金,一半的Fab大小,包括影子
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <View android:id="@+id/header" android:layout_width="match_parent" android:layout_height="120dp" /> <View android:id="@+id/body" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@id/header" /> <fully.qualified.name.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_alignBottom="@id/header" android:layout_marginBottom="-32dp" android:layout_marginRight="20dp" /></RelativeLayout>
- 3 回答
- 0 关注
- 528 浏览
添加回答
举报
0/150
提交
取消