Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Float action button anchor with include layout

do you know if it is possible to use the id views included in a layout as anchor of a FAB ? For example :

<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" is inside the inclued layout content_main.

With this code I currently get the follow error:

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

For information I'm use the include for trying to reduce my main layout size.

It seem that "@id/map" is not visible for the FAB anchor. But I perhaps doing something wrong.

like image 621
Jérôme Avatar asked Jun 26 '26 22:06

Jérôme


1 Answers

I guess you are missing Tag Id android:id="@+id/map"

Open your @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').
like image 62
IntelliJ Amiya Avatar answered Jun 29 '26 11:06

IntelliJ Amiya