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.