Adjust icon size of Floating action button (fab)
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.
Floating action button (Fab) Icon size problems after migrating to sdk 28
So if someone is having the same problem :
Till now there is no good enough XML option to fix the issue (If you
know one please post an answer to the question it would be much appreciated )
But programmatically you can do this guys:
FloatingActionButton fab = findViewById(R.id.fab);
fab.setScaleType(ImageView.ScaleType.FIT_CENTER);
Android Floating Action button : Resize inside icon
try this: in Layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="0dp"
android:scaleType="fitXY"
android:src="@drawable/map"
app:backgroundTint="@android:color/transparent"
app:borderWidth="0dp"
app:useCompatPadding="true" />
</RelativeLayout>
Now in res/values/dimens.xml:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="fab_margin">16dp</dimen>
<dimen name="design_fab_image_size" tools:override="true">56dp</dimen>
</resources>
This line is important <dimen name="design_fab_image_size" tools:override="true">56dp</dimen>
output:
Change size of FloatingActionButton
Wrap the FloatingActionButton
in a Container
, specifying the width and height.
You can override the size of the icon to make it look more natural:
Container(
width: 80.0,
height: 80.0,
child: FloatingActionButton(
onPressed: () {},
child: Icon(
Icons.add,
size: 30.0,
),
),
);
I was pleased to discover the notch size is adjusted accordingly if you are embedding this button in a BottomAppBar
.
How to resize icon inside fab button
You can try to use app:maxImageSize="your_image_max_size"
Hope this helps.
How to change the size of FloatingActionButton?
Use a Container
where you can specify width
and height
, then use a RawMaterialButton
, like this:
final myFabButton = Container(
width: 200.0,
height: 200.0,
child: new RawMaterialButton(
shape: new CircleBorder(),
elevation: 0.0,
child: Icon(
Icons.favorite,
color: Colors.blue,
),
onPressed: () {},
),
);
Android: How to change size of app:fabSize=normal for Floating Action Button
There are two different sizes of FAB
available: normal
or mini
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.
Android: Create bigger Floating Action Button with bigger icon
You can try to redefine the maximum size of the fab image size in your dimensions.xml
:
<resources xmlns:tools="http://schemas.android.com/tools">
<dimen name="design_fab_size_mini" tools:override="true">80dp</dimen>
<dimen name="design_fab_content_size" tools:override="true">48dp</dimen>
</resources>
Must make sure you override the original resources in the Design Library. Try design_fab_image_size
instead of design_fab_content_size
if this does not work for you.
Use with care as this is a hack not an actual solution. Solution might not work if the resource's name is changed in the future Design Library release. My opinion is to stick with the size that is define in the Design Library as it is the recommended design guideline based on the Material Design which make your overall app looks good.
What is the best image size of floating action button
According to Material Design Guidelines 24 x 24dp:
Related Topics
What Are the Overheads of Using Autoincrement for SQLite on Android
Getting Null Device Id While Registering to Gcm
Moving or Copying Data from One Node to Another in Firebase Database
Out of Memory Error While Loading Bitmaps
Android Ble Bluetoothgatt.Writedescriptor() Return Sometimes False
How to Deal with Different Aspect Ratios in Libgdx
Where Is the All Android Broadcast Intent List
Android Opengl .Obj File Loader
What Is the Meaning of Android.Intent.Action.Main
Using the "Animated Circle" in an Imageview While Loading Stuff
How to Read/Write a Boolean When Implementing the Parcelable Interface
I Want My Android Application to Be Only Run in Portrait Mode
Ios/Android Cross Platform Development
Differencebetween the States Selected, Checked and Activated in Android