You will get often different results given the same minWidth and minHeight values. With all that wild world of different screen sizes and densities and 3rd party launchers, it's very difficult to get consistent result with home screen widgets. I wonder why Google opted to specify sizes with dps, doing it directly with number of cells would be much better...
The best you can do is: - don't use the old formula, that was used in the "dark ages" of appwidgets - feel free to try different minWidth and minHeight values according to the device specifications, i.e. experiment using different values in xml / xml-sw600dp / xml-sw720dp etc. if you really want to achieve an specific number of cells - just live with the fact that some obscure launcher will do the math according to its own criteria and will decide that your perfectly crafted 4x1 widget is a 3x1 one (I'm looking at you Google Now Launcher) (I'm serious about Google Now Launcher, my widget comes in two sizes, 3x2 and 4x3, this Google-owned launcher presents them as 2x2 and 3x3. And the minWidth and minHeight values are perfectly set to Google's specifications) Good luck José https://play.google.com/store/apps/developer?id=Jos%C3%A9+Gonz%C3%A1lez+D%27Amico El domingo, 25 de enero de 2015, 8:59:20 (UTC-3), BArtWell escribió: > > I need to make a widget with size 4x1 cells. Here is my code: > <appwidget-provider xmlns:android=" > http://schemas.android.com/apk/res/android" > > > > > android:minWidth="250dp" > > android:minHeight="40dip" > > android:updatePeriodMillis="0" > > android:initialLayout="@layout/widget" > > android:configure="ru.bartwell.myapp.WidgetActivity" /> > > > I test it on two virtual devices in Genymotion: > > > 1. Google Nexus 7, 800x1280, Android 4.4.4 > 2. Samsung Galaxy S5, 1080x1920, Android 4.4.4 > > And I get different results: > > When android:minWidth="250dp" and android:minHeight="40dip" (new formula): > > > 1. Google Nexus 7 - 3x1 cells > 2. Samsung Galaxy S5 - 4x1 > > When android:minWidth="292dp" and android:minHeight="70dip" (old formula): > > > 1. Google Nexus 7 - 4x1 > 2. Samsung Galaxy S5 - 4x2 > > As I see widget size depends of screen resolution. But I just need to get > 4x1 widget's size on all devices. How to correctly setup widget size? > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

