I'm trying to replace the third party FloatingActionButton with the native one which is packaged in library com.android.support:design:22.2.0
.The default look has a dark shadow around the image,How can I get rid of it? I know the former one provides with the method setShadow()
,but I just can't find similar one from the latter.
This is the related XML layout:
<android.support.design.widget.FloatingActionButton android:id="@+id/alarm_front" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/btn_icon_alarm_notset" />
And I have set its background color to yellow.
mAlarmBtn.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.floatButtonColor)));
To remove shadow of Floating Action Button in Kotlin Android, set the elevation attribute (in layout file) to 0dp or set compatElevation parameter (in Kotlin program) of FAB with floating point value of 0.0f.
To show and hide a FloatingActionButton with the default animation, just call the methods show() and hide() . It's good practice to keep a FloatingActionButton in the Activity layout instead of putting it in a Fragment, this allows the default animations to work when showing and hiding.
Add the floating action button to your layoutThe 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 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.
Override the default elevation of the FAB by adding:
android:elevation="0dp"
Or in code call View.setElevation(float)
Add this
android:elevation="0dp" app:elevation="0dp"
It's will be like :
<android.support.design.widget.FloatingActionButton android:id="@+id/floatingActionButton" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/ic_add" android:elevation="0dp" app:elevation="0dp" app:fabSize="normal" android:scaleType="fitCenter"/>
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