Floating Action Button을 두 레이아웃 사이에 추가하고싶습니다.
조회수 7041회
안드로이드에 새로 추가된 FAB라고들 하는 floating action button있잖아요.
여기에서 분홍색 버튼이요. 제 질문은 제가 여러가지로 노력을해봤는데 위의 그림처럼 두 레이아웃사이에 FAB를 추가하는 방법을 모르겠습니다. 어떻게 할지 방법좀 가르쳐주세요.
1 답변
-
우선 build.gradle에 'com.android.support:design:23.1.1' 를 추가시킵니다.
<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>
이걸 따라하시면됩니다.
댓글 입력