1

I have a widget with 2 oval buttons (defined in a XML file). At the moment, I've hard coded the width and height of the button to 180dp, but this poses problems when making the widget smaller.

Is there anyway I can set the width and height of the button to scale as the widget size is changed?

Boots
  • 224
  • 1
  • 4
  • 16
  • You can specify the minimum widget size using minResizeWidth and minResizeHeight. Also I would suggest you to go through, http://developer.android.com/guide/practices/ui_guidelines/widget_design.html#design – Anirudh May 29 '13 at 10:17
  • I've got that specified. I'm talking about components in the widget. When the widget is made smaller, the button's still stay the same size and destroys the layout. I wan't the buttons to scale down/up if the widget is resized. – Boots May 29 '13 at 10:50

1 Answers1

2

Resizable widgets are preferred feature for collection widgets such as those based on ListView or GridView. App Widget Design Guideline

So for your purpose it's better to use different layout if your widget gets resized. On Android 4.1 and above you may use onAppWidgetOptionsChanged() method to load different layout when your widget is resized. See these answers for more information:

  1. How to use onAppWidgetOptionsChanged() in a widget?
  2. define widget's behaviour/layout for resize and orientation change
Community
  • 1
  • 1
Sam R.
  • 16,027
  • 12
  • 69
  • 122