Adjust icon size of Floating action button fab
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In Android Material design, Floating Action Button icon size is controlled separately from the button diameter. Many developers resize the whole button when they only need a larger or smaller icon. The clean fix is to keep standard FAB dimensions and adjust icon rendering through XML attributes or custom drawables.
Understand Button Size Versus Image Size
A regular FAB has predefined dimensions through Material components. Icon size is constrained by image padding and internal limits. If icon appears too small, first verify asset viewport and then set explicit image size.
In XML, use app:maxImageSize on FloatingActionButton:
This keeps the FAB itself standard while allowing a larger icon area.
Use Proper Vector Drawable Viewport
If icon still looks off, the drawable may have a viewport mismatch. A 24 unit viewport with tiny path content can appear undersized even when maxImageSize is larger.
Keep path geometry proportionate to viewport bounds for consistent sizing.
Programmatic Control in Kotlin
You can set icon size dynamically for responsive layouts or feature flags.
For icon scale behavior, ensure android:scaleType and drawable intrinsic size are not fighting each other.
Design Consistency Recommendations
Even if larger icons are possible, maintain touch target and visual rhythm across screens. Material guidance favors clear contrast and moderate icon proportions rather than oversized symbols.
When different FAB styles are needed, define style resources instead of hardcoding values repeatedly. This keeps accessibility adjustments and theme changes manageable.
Material Size Variants and Accessibility
Before changing icon size, review whether you should use standard or mini FAB variants. Mini FAB is appropriate for dense layouts, while standard FAB is better for primary screen actions. Icon adjustments should preserve visual contrast and tap target size.
Keep touch targets at accessible dimensions even if visual icon appears smaller. You can check interaction area using layout inspector tools and accessibility scanner.
Theme Driven Reuse
Define a style for FAB icon sizing when multiple screens use the same scale. This avoids inconsistent values spread across layout files.
Then apply style reference in XML for maintainable design updates.
Common Pitfalls
- Resizing FAB width and height when only icon size needs adjustment.
- Using low quality bitmap assets that blur after scaling.
- Ignoring vector viewport proportions, causing unexpected visual size.
- Applying extreme icon size that reduces internal padding and clarity.
- Setting runtime pixel values without density conversion.
Summary
- FAB diameter and icon size are separate configuration concerns.
- Use
app:maxImageSizefor direct icon sizing control. - Validate vector drawable viewport so icon fills expected area.
- Convert dp to pixels when setting size programmatically.
- Keep icon scale consistent with Material design and accessibility goals.
- Prefer style resources for icon sizing to keep visual consistency across feature modules and simplify future design updates.
- Run visual regression checks on multiple densities so icon size decisions remain consistent across low and high resolution devices.

