Open In App

Widgets in Android 12

Last Updated : 19 Sep, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

Prior to Android 12, users had to remove their current widget and add it again with the new configuration when changing a widget. Android 12 enhances the way widgets are configured in a variety of ways and makes it easier for users to customize widgets. Reconfigurable widgets allow users to tailor the widget to their own needs. With Android 12, they won’t have to delete and re-add the widget to change these settings.

How to Achieve it?

To allow this, set the widgetFeatures property in the appwidget-provider to reconfigurable.

<appwidget-provider
<!-- Geeks for Geeks -->
    android:configure="com.geeksforgeeks.sampleApp.androidTwelve.ListWidgetConfigureActivity"
    android:widgetFeatures="reconfigurable"
    ... />

Configuration by Default

If your widget can be configured with the default settings, you may skip the first configuration activity and set up the widget with the default settings in Android 12.

Check that Your Widget is Android 12 Compliant

Android 12 widgets feature rounded corners. The widget is resized and is cropped to round edges forced by the launcher and the Android Operating systems or the OEMs. In this case, your widget may not appear properly if one of the following circumstances exists:

  1. The widget makes use of a backdrop that cannot be cropped. This includes translucent backgrounds, empty views or layouts, and any other unique backdrop that is not susceptible to cropping.
  2. The widget has the following content in the corners: Some content in the corner region may be clipped as a result of this.

Additional widget sizing limitations can be specified:

Android 12 introduces new APIs that allow you to ensure your widget is consistently scaled across devices with varied screen sizes. You may use all the different various size providers in the available android documentation to make your workflow projects go smoothly and upgrade your widgets to Android 12

Layouts that are Responsive:

Although scaling restrictions can assist users in resizing a widget to meet their needs, you may wish to provide alternative layouts and content types that will be used based on the size of the widget. This also allows the system to change the size of the widget without waking up the program. When the size of the widget changes, the system automatically adjusts the layout.

APIs that are new and enhanced:

There are many various form factors to select from when it comes to Android devices, whether it’s a phone, tablet, foldable, or another type of product. To make widgets easier to modify and more dependable across multiple devices and screen sizes, Android 12 provides improved size characteristics and more flexible layouts.

Visual Modifications:

It’s no wonder that people notice the most obvious improvements in style and design. Updating aesthetic components such as colors and corner radius results in an instantly more updated appearance. We recommend building a custom theme to begin applying these modifications.

Incorporate Dynamic Colors:

The new changes in the overall system add some dynamic pinch to the color of the widget and they now also depend on the Night and Day Modes of the device on which they are running. Widgets can utilize Theme, the system’s default theme. DeviceDefault. DayNight and utilize theme color properties on the widget’s UI components.

Conclusion

You’ve seen how to alter your widget’s look and provide a better user experience in the widget picker in this post. These are low-hanging fruits for starting to update your widgets for Android 12, and your users will notice the aesthetic change right away.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads