Android application developers aim to capture users' attention by customizing and theming android application widgets to attract more traffic and customers based on the design of the application. This article focuses on theming one of the crucial UI elements, the Floating Action Buttons (both extended and normal). Below, you will find sample images of Theming Floating Action Buttons.
Add the necessary dependency to the app level Gradle file to incorporate the Floating Action Button provided by the Google Material Design Team. You can include the dependency in the build.gradle(app) file as follows:
|
android:backgroundTint="@color/colorAccent"
property.@color/colorAccent
as the background tint will adjust the color of the FABs accordingly.styles.xml
file.styles.xml
, such as ShapeAppearance.App.SmallComponent
.cornerFamily
to customize the appearance of the FABs.Output: After applying changes to styles.xml
, run the app on an emulator to view the updated appearance.
Exploring further, let's delve into an example to understand the practical implementation of these theme alterations.
By following these steps, developers can efficiently tailor the visual appearance and design of Floating Action Buttons in their Android applications.
Upon updating the styles.xml file, the user interface reflects the applied changes.
The colors of both FABs are made different in this case for demonstration purposes only. It is not recommended; according to material design recommendations, the colors of all FABs should be the same throughout the application.
Experiment with the children "customNormalFAB" and "customExtendedFAB" to make changes in the shapes of both the FABs. Also, experiment with "cornerSizeTopRight," "cornerSizeTopLeft," "cornerSizeBottomRight," and "cornerSizeBottomLeft." Make changes to both children as follows:
<!--for Extended FAB--> | <style name="customExtendedFAB"> |
<!--for the extended FAB, the cornerFamily is given the value as "cut"--> | <item name="cornerFamily">cut</item> |
<!--this attribute will make changes to Top Right according to value--> | <item name="cornerSizeTopRight">0dp</item> |
<!--this attribute will make changes to Top Left according to value--> | <item name="cornerSizeTopLeft">0dp</item> |
<!--this attribute will make changes to Bottom Right according to value--> | <item name="cornerSizeBottomRight">0dp</item> |
<!--this attribute will make changes to Bottom Left according to value--> | <item name="cornerSizeBottomLeft">0dp</item> |
</style> | |
<!--for Normal FAB--> | <style name="customNormalFAB"> |
<!--for the extended FAB, the cornerFamily is given the value as "cut"--> | <item name="cornerFamily">cut</item> |
<!--this attribute will make changes to Top Right according to value--> | <item name="cornerSizeTopRight">0dp</item> |
<!--this attribute will make changes to Top Left according to value--> | <item name="cornerSizeTopLeft">0dp</item> |
<!--this attribute will make changes to Bottom Right according to value--> | <item name="cornerSizeBottomRight">0dp</item> |
<!--this attribute will make changes to Bottom Left according to value--> | <item name="cornerSizeBottomLeft">0dp</item> |
</style> |
Output UI will be:
When customizing Floating Action Buttons in Android, certain attributes can be adjusted to achieve different visual effects:
Login
Like