其他分享
首页 > 其他分享> > 浮动操作按钮锚点包含布局

浮动操作按钮锚点包含布局

作者:互联网

您知道是否可以将布局中包含的id视图用作FAB的锚点吗?例如 :

<include layout="@layout/content_main" />

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_anchor="@id/map"
    app:layout_anchorGravity="bottom|right|end"
    android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_menu_add" />

“ @ id / map”位于包含的布局content_main中.

有了这段代码,我目前得到以下错误:

Error:(30, 28) No resource found that matches the given name (at
‘layout_anchor’ with value ‘@id/map’).

有关信息,我使用include尝试减小主布局的大小.

对于FAB锚,似乎“ @ id / map”不可见.但是我也许做错了什么.

解决方法:

我猜您缺少标签ID android:id =“ @ id / map”

打开您的@ layout / content_main

Floating action buttons are used for a special type of promoted
action. They are distinguished by a circled icon floating above the UI
and have special motion behaviors related to morphing, launching, and
the transferring anchor point.

Error:(30, 28) No resource found that matches the given name (at 'layout_anchor' with value '@id/map').

标签:material-design,android
来源: https://codeday.me/bug/20191027/1944007.html