Floating Action Button Positioning with Drawer and fragment view
jianglin612 opened this issue · 3 comments
jianglin612 commented
I currently am using a fragment and then also have a drawer. The code is as follows... Unfortunately this makes the Floating action button appear at the TOP LEFT instead of the bottom right area. Any idea how to fix?
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The main content view -->
<RelativeLayout
android:id="@+id/mainContent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/listview_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="@drawable/upvote"
fab:fab_colorNormal="@color/material_blue_grey_800"
fab:fab_colorPressed="@color/white"
fab:fab_colorRipple="@color/blue" />
</RelativeLayout>
<!-- The navigation drawer -->
<RelativeLayout
android:layout_width="280dp"
android:layout_height="match_parent"
android:id="@+id/drawerPane"
android:layout_gravity="start">
<!-- Profile Box -->
<RelativeLayout
android:id="@+id/profileBox"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@color/material_blue_grey_800"
android:padding="8dp" >
<ImageView
android:id="@+id/avatar"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/upvote"
android:layout_marginTop="15dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="42dp"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@+id/avatar"
android:orientation="vertical" >
<TextView
android:id="@+id/userName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TOWNHALL"
android:textColor="#fff"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginTop="4dp"
android:text="View Profile"
android:textColor="#fff"
android:textSize="12sp" />
</LinearLayout>
</RelativeLayout>
<!-- List of Actions (pages) -->
<ListView
android:id="@+id/navList"
android:layout_width="280dp"
android:layout_height="match_parent"
android:layout_below="@+id/profileBox"
android:choiceMode="singleChoice"
android:background="#ffffffff" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
jdzuri commented
Hi,
I experimented the same issue. FloatingActionButton isn't positioned correctly inside a RelativeLayout
.
Try to change the RelativeLayout
that contains the FloatingActionButton by FrameLayout
.
jianglin612 commented
I winded up doing that already, it solved the issue (although required another layer) Thanks!