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…

xcode tutorial for beginners

7 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *