I\'m trying to create a floating button in my app. The button is there, but the image in the button is a bit upwards (see image).
I can\'t figure out what\
You should set fabCustomSize value like FAB exactly size:
<android.support.design.widget.FloatingActionButton
android:layout_width="60dp"
android:layout_height="60dp"
app:fabCustomSize="60dp"
android:src="@drawable/plus_icon"
app:rippleColor="@color/colorPrimaryDark" />
Best solution is not to hardcode the FAB's dimension.
Icon will be centered with attribute android:scaleType="center"
<android.support.design.widget.FloatingActionButton
android:id="@+id/search_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:layout_marginEnd="10dp"
android:src="@drawable/fab_search_icon"
app:backgroundTint="@color/colorPrimary"
app:elevation="4dp"
app:fabSize="normal"/>
This usually arises when using custom-sized floating action button(FAB), because android by default, only supports 40dp FAB. The best way is to override it, by telling your view that you are using a custom sized FAB, and give the same size as value to it too.
For example, while using a 60dp x 60dp FAB, this will do the trick.
app:fabCustomSize="60dp"