I tried to setup a fab by using the support design library.
Code in XML:
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/fab"
android:src="@drawable/ic_add_white_18dp"
app:borderWidth="2dp"
app:fabSize="normal"
android:onClick="submit"
app:rippleColor="@color/colorPrimaryDark">
</android.support.design.widget.FloatingActionButton>
On Nexus 6(lollipop), the plus icon is rendering correctly.
But on nexus 4(pre lollipop), plus icon size is crossing the circle.
I have downloaded and used the plus(ic_add_white_18dp) from Material icons
Icon Sizes used:
mdpi - 18dp
hdpi - 27dp
xdpi - 36dp
xxdpi - 54dp
What should be the correct size to use for plus icon.
Add the floating action button to your layout The size of the FAB, using the app:fabSize attribute or the setSize() method. The ripple color of the FAB, using the app:rippleColor attribute or the setRippleColor() method. The FAB icon, using the android:src attribute or the setImageDrawable() method.
To change the shape of the Floating action button: You can use the shape property of FloatingActionButton() widget class. Implement BeveledRectangleBorder( ) on this property. The output will be a square floating action button, increase the border-radius value to make a circular type shape.
To change background color of Floating Action Button in Kotlin Android, set the backgroundTint attribute (in layout file) or backgroundTintList property (in Kotlin file) of FAB with the required color.
This has been fixed as of v22.2.1.
As it was stated on FloatingActionButton, square button below API level 17
Which referenced this bug: https://code.google.com/p/android/issues/detail?id=175067
Your FAB should have app:borderWidth="0dp"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With