I'm currently facing two different issues, both regarding fab gravity behavior.
In my layout I have a section consisting in a FrameLayout
with an ImageView
and a FloatingActionButton
as children views.
`<RelativeLayout ...>
*Here's a toolbar*
<ScrollView ...>
<LinearLayout ...>
<FrameLayout
android:id="@+id/prof_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/activity_vertical_margin">
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/profile_image"
android:layout_width="@dimen/size_editing_pic"
android:layout_height="@dimen/size_editing_pic"
android:src="@drawable/ic_profilo_utente"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/floating_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:scaleType="center"
android:tint="@color/dark_gray"
app:layout_anchor="@id/profile_image"
app:layout_anchorGravity="bottom|end|right"
app:srcCompat="@drawable/ic_camera"
app:backgroundTint="@color/colorAccentEasy"
app:fabSize="mini"/>
</FrameLayout>
*Other sections*
</LinearLayout>
</ScrollView>
</RelativeLayout>`
- Issue 1: Android version >= Lollipop
The FAB is right where it should be but you can see that its shadow is clearly cut without the supposed fading.
- Issue 2: Android version < Lollipop
The FAB is not where it's supposed to be.
I tried anything that came to my mind and that I found online and here on SO.
I understand that it has to do with the different padding management that the core code does if the OS is pre or post Lollipop, and with the attribute useCompatPadding
(which I tried in different combinations), but I can't figure out how to successfully resolve it.
UPDATE
Thanks to the suggestion I managed to solve Issue #1.
As far as Issue #2 is concerned, though, I still can't solve it.
In my new fabStyle-v21 a layout_margins
of 5dp since it perfectly suited my needs.
I then tried putting a 0dp margin in the default style, but still nothing, even trying negative margins.