When you design an app widget, you specify a minimum width and height for that widget. When the user places a new widget, the minimum width and height appear to translate across to a default widget size (in terms of blocks).
In other words, the initial widget layout appears to correspond to the minimum widget size specified (which they can subsequently resize).
Is it possible to specify that you want the widget initially to be laid out according a default size, whilst also setting the minimum dimensions below which the user cannot resize the widget later?
In my case, there is a size at which I think the widget looks best, but it still looks OK below that size if the user really wants to save on space. So I want to set the default at what I think looks best, and the minimum at what truly is the lower limit.
For resizable widgets, press firmly on the widget on your home screen. 2. A white box with circular adjustment markers will appear around the widget. Slide them in or out to make the widget smaller or larger, respectively.
There are, in general, four types of widgets: information widgets, collection widgets, control widgets, and hybrid widgets.
App widgets are miniature application views that can be embedded in other applications (such as the home screen) and receive periodic updates. These views are referred to as widgets in the user interface, and you can publish one with an app widget provider (or widget provider).
That is correct - in the metadata definition of for your app widget provider info you can use
minWidth and minHeight to define your desired / default / best widget size and minResizeWidth and minResizeHeight to define the smallest allowed widget size
For example:
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="286.0dp"
android:minHeight="146.0dp"
android:resizeMode="vertical|horizontal"
android:minResizeWidth="146.0dp"
android:minResizeHeight="72.0dp"
/>
In this case the default size is 4 x 2 cells, and the minimum size is 2 x 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With