I'm trying to figure out how can be modified FloatingActionButton from android support library. Can it be used with the text instead of image?
Something like this one:
I see it extends ImageButton so I think not. Am I right?
Is this correct in terms of Material Design in general?
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.
Add a Text("YourText") widget in child of FloatingActionButton. Then it will work.
Extended Floating Action Button is the newly introduced class with Material Components library in Android. Material Components is introduced with SDK 28 or Android P. It's a superset of Support Design Library with lots of new additions and improvements.
Thanks to all.
Here is easy workaround which I found for this question. Works correctly for Android 4+, for Android 5+ is added specific parameter android:elevation to draw TextView over FloatingActionButton.
<FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|right"> <android.support.design.widget.FloatingActionButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@android:color/transparent" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="@android:string/ok" android:elevation="16dp" android:textColor="@android:color/white" android:textAppearance="?android:attr/textAppearanceMedium" /> </FrameLayout>
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