android - How can I add the new "Floating Action Button" between two widgets/layouts -
i guess have seen new android design guidelines, new "floating action button" a.k.a "fab"
for instance pink button:
my question sounds stupid, , have tried lot of things, best way put button @ intersection of 2 layouts?
in above exemple, button placed between can imagine imageview , relativelayout.
i have tried lot of tweaks, convinced there proper way it.
best practice:
- add
compile 'com.android.support:design:25.0.1'
gradle file - use
coordinatorlayout
root view. - add
layout_anchor
to fab , set top view - add
layout_anchorgravity
fab , set to:bottom|right|end
<android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <linearlayout android:id="@+id/viewa" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="0.6" android:background="@android:color/holo_purple" android:orientation="horizontal"/> <linearlayout android:id="@+id/viewb" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="0.4" android:background="@android:color/holo_orange_light" android:orientation="horizontal"/> </linearlayout> <android.support.design.widget.floatingactionbutton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="16dp" android:clickable="true" android:src="@drawable/ic_done" app:layout_anchor="@id/viewa" app:layout_anchorgravity="bottom|right|end"/> </android.support.design.widget.coordinatorlayout>
Comments
Post a Comment