为了账号安全,请及时绑定邮箱和手机立即绑定

如何在两个小部件/布局之间添加新的“浮动操作按钮”

如何在两个小部件/布局之间添加新的“浮动操作按钮”

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

3 回答

?
缥缈止盈

TA贡献2041条经验 获得超4个赞

在本例中,似乎最干净的方法是:

  • 使用RelativeLayout
  • 将两个相邻视图放置在另一个下面。
  • 将Fab对齐到父的右/端,并添加一个右/尾边距。
  • 将Fab对齐到标头视图的底部,并添加

    保证金,一半的Fab大小,包括影子

例子改编自萨满国的实施,使用任何你想要的Fab。假设Fab为64 dp,包括阴影:

<?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>


查看完整回答
反对 回复 2019-07-04
  • 3 回答
  • 0 关注
  • 528 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号