The new floating action button should be 56dp x 56dp and the icon inside it should
As your content is 24dp x 24dp you should use 24dp icon. And then set android:scaleType="center"
in your ImageButton to avoid auto resize.
What's your goal?
If set icon image size to bigger one:
Make sure to have a bigger image size than your target size (so you can set max image size for your icon)
My target icon image size is 84dp & fab size is 112dp:
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src= <image here>
app:fabCustomSize="112dp"
app:fabSize="auto"
app:maxImageSize="84dp" />
Make this entry in dimens
<!--Floating action button-->
<dimen name="design_fab_image_size" tools:override="true">36dp</dimen>
Here 36dp is icon size on floating point button. This will set 36dp size for all icons for floating action button.
Updates As Per Comments
If you want to set icon size to particular Floating Action Button just go with Floating action button attributes like app:fabSize="normal" and android:scaleType="center".
<!--app:fabSize decides size of floating action button You can use normal, auto or mini as per need-->
app:fabSize="normal"
<!--android:scaleType decides how the icon drawable will be scaled on Floating action button. You can use center(to show scr image as original), fitXY, centerCrop, fitCenter, fitEnd, fitStart, centerInside.-->
android:scaleType="center"
If you are using androidx 1.0.0 and are using a custom fab size, you will have to specify the custom size using
app:fabCustomSize="your custom size in dp"
By deafult the size is 56dp and there is another variation that is the small sized fab which is 40dp, if you are using anything you will have to specify it for the padding to be calculated correctly
As FAB
is like ImageView
so You can use scaleType
attribute to change the icon size likewise ImageView
. Default scaleType
for a FAB
is fitCenter
. You can use center
and centerInside
to make icon small and large respectively.
All values for scaleType
attribute are - center, centerCrop, centerInside, fitCenter, fitEnd, fitStart, fitXY
and matrix
.
See https://developer.android.com/reference/android/widget/ImageView.ScaleType.html for more details.