When using the new FloatingActionButton
, the size is determined by app:fabSize="normal"
. How can I set what in dp
is the size referenced by "normal"
?
I tried to create values/attrs.xml
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="app">
<attr name="fabSize">
<enum name="mini" value="50dp" />
<enum name="normal" value="100dp" />
</attr>
</declare-styleable>
</resources>
But I get the error
"normal" in attribute "fabSize" is not a valid integer
•
Standard Sizes
There are three options for standard
FAB
sizes (according to developer.android) which you can set them usingapp:fabSize
..
.
•
Custom Sizes
To set custom
FAB
size you can setapp:fabCustomSize
. Note thatandroid:layout_width
andandroid:layout_height
should be"wrap_content"
.To change Fab size and to see large image init i have made below changes in android api 28:- thew are as
where in dimens.xml
Just user app:fabCustomSize in xml
Bingo.
There are two different sizes of
FAB
available:normal
ormini
Normal (56dp)
— This size should be used in most situations.Mini (40dp)
— Should only be used when there is a need for visual continuity with other components displayed on the screen.I know it's not recommended, but for those that absolutely need to change the default sizes, I was able to do it by wrapping the
FloatingActionButton
in aLinearLayout
.