Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App Widget: can you specify a minimum AND a default size?

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.

like image 554
drmrbrewer Avatar asked Oct 28 '14 12:10

drmrbrewer


People also ask

How do I change the size of my widgets on Android?

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.

What are the types of widgets?

There are, in general, four types of widgets: information widgets, collection widgets, control widgets, and hybrid widgets.

What is an app widget?

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).


1 Answers

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

like image 135
ra3o.ra3 Avatar answered Sep 23 '22 20:09

ra3o.ra3