I am doing some operation on floating action button . I have a list view and showing google ad at bottom of my screen, The floating action button is showing at same place (bottom|end). so action button is hiding the ad.
I want shift the Floating action button little above the ad linear layout.
My code is look like:
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|end"
android:src="@drawable/fav"
android:adjustViewBounds="false" />
adLayoutId is ad layout id
Please help.
Thanks in advance.
Add a bottom Margin of 55dp which is the size of Admob Banners
This line in either the floating button or enclosing layout.
android:layout_marginBottom="55dp
THESE TWO LINES ARE IMPORTANT.
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
You should use
RelativeLayout
, and as we know, later children in aRelativeLayout
tend to float over earlier children in aRelativeLayout
.So, to have a FAB float over of any layout, make sure that the FAB is defined after all views (at the end of the XML layout).
If you use
android:layout_margin="@dimen/fab_margin"
the best way to manipulate FAB is set dependencies between views, for example:Floating action button always will be above the ad linear layout, and independent from ad layout size. Hope it helps.