android - CoordinateLayout app:layout_anchor and app:layout_anchorGravity not working in fragments -
i'm using coordinatelayout
in fragment's layout file. there need use floatingactionbutton
or imagebutton
between 2 layouts. got sample code this answer.
i created 2 fragments 2 same layout file. fragment1.xml, fragment2.xml
<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.4" 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.6" 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/icon_add_new" app:layout_anchor="@id/viewa" app:layout_anchorgravity="bottom|right|end"/> </android.support.design.widget.coordinatorlayout>
when run app fragment1 show after button click fragment2 show. when replacing first fragment second fragment button position changed top left corner below.
fragment 1
fragment 2
i can't understand why? can me?
Comments
Post a Comment