Floating Action Button을 두 레이아웃 사이에 추가하고싶습니다.

조회수 7041회

안드로이드에 새로 추가된 FAB라고들 하는 floating action button있잖아요.

1

여기에서 분홍색 버튼이요. 제 질문은 제가 여러가지로 노력을해봤는데 위의 그림처럼 두 레이아웃사이에 FAB를 추가하는 방법을 모르겠습니다. 어떻게 할지 방법좀 가르쳐주세요.

1 답변

  • 좋아요

    0

    싫어요
    채택 취소하기

    우선 build.gradle에 'com.android.support:design:23.1.1' 를 추가시킵니다.

    2

    <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>
    

    이걸 따라하시면됩니다.

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)