简体   繁体   中英

Scaling Android Widget

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM