App Widget Part 3 - CHANGING THE LAYOUT ON RESIZE - Android Studio Tutorial

In part 3 of the app widget tutorial, we will override the onAppWidgetOptionsChanged, onDeleted, onEnabled and onDisabled callback methods, which will be triggered over broadcasts at different points of the lifecycle of our widget. OnEnabled will be called every time we delete a widget, onEnabled will be called when we place our first widget on the home screen but not for any additional one, and onDisabled will be called when we delete our last widget from the home screen. We will take a closer look at onAppWidgetOptionsChanged, because this method will be called when we change the size of our widget. Here we get passed 4 different width/height values, which are: OPTION_APPWIDGET_MIN_WIDTH, OPTION_APPWIDGET_MAX_WIDTH, OPTION_APPWIDGET_MIN_HEIGHT and OPTION_APPWIDGET_MAX_HEIGHT. The min width and max height are the dp dimensions of our widget when the device is in portrait mode, and depending on their value we can change the app widget's layout, for example by making views invisible when the available space is too small. The same as in onUpdate we have to call updateAppWidget on the AppWidgetManager and pass an RemoteViews object to apply the changes to our widget. Watch the whole playlist: Example code for this part: ____________________ ? Find the BEST programming tutorials on TutHub: ⭐ Get my MVVM Caching Course now: ❗ Subscribe to the channel: ? Subscribe to the Coding in Flow newsletter: ❓ Join our free developer community: ? Follow Coding in Flow on other...

0/0


0/0

0/0

0/0

0/0