Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to create floating action button layout in android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.08k
    Comment on it

    In the below code layout I have created floting action button layout. Here I have used CoordinatorLayout, LinearLayout, TextView and FloatingActionButton. FloatingActionButton move left or right when we changes layout_anchorGravity. In this layout FloatingActionButton is under LinearLayout id/viewA.
    You can see the below example it will clearly describe you how to create Floting action button layout in android.

    <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"
                android:textAlignment="center">
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Evon"
                    android:textSize="40dp"
                    android:textStyle="bold"
                    android:textAlignment="center"/>
                </LinearLayout>
    
            <LinearLayout
                android:id="@+id/viewB"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="0.5"
                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/icon2"
            app:layout_anchor="@id/viewA"
            app:layout_anchorGravity="bottom|end|right"/>
    
    </android.support.design.widget.CoordinatorLayout>
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: