title: Android app widget size problems
body: <p>I am having some issues with the getting the size of a home screen widget I am designing. I've read the sdk documentation and done a bit of searching, but I'm not really finding anything useful. Anyway, I am using the onAppWidgetOptionsChanged method of the widget provider to get the widget size on devices above API 16, and it reports incorrectly on some devices. It functions correctly on a Nexus S and a Transformer Prime, but the values it gives on my S3 is smaller than what I measured from a screenshot. I have accounted for the fact that it is reported in dp instead of pixels. I'm guessing that there is some type of margin being added by Samsung's launcher, but I can't find any correlation. For example, when I use a 2x2 widget, onAppWidgetOptionsChanged reports 154dp (~293px) width and 193dp (~355px) height, but I measured ~340px by 420px in Photoshop. Is this a Samsung only problem, or am I going to face this on many non-vanilla platforms. The code is pretty basic, but I am posting any just in case.</p>
  
  <pre><code>@Override
  public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions) {
      int minWidth = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);
      int maxWidth = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH);
      int minHeight = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);
      int maxHeight = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT);
  
      Log.i("WidgetProvider","Widget size changed");
      Log.i("WidgetProvider","minWidth: " + minWidth);
      Log.i("WidgetProvider","minHeight: " + minHeight);
      Log.i("WidgetProvider","maxWidth: " + maxWidth);
      Log.i("WidgetProvider","maxHeight: " + maxHeight);
  }
  </code></pre>
  
  <p>I am using the size reported to generate a bitmap in my widget update service. I need to use a custom bitmap because I want use custom fonts and backgrounds for my widget. On devices below API 16, I just set the bitmap to the minWidth and minHeight defined in the widget info xml. On some devices this leaves more padding than I would prefer around the widget, but the image is undistorted. As I understand, there is no way of getting the widget size in earlier devices. Also, I don't believe custom fonts can be used in a TextView in an app widget. Is this correct? I have tried using fitXY with the image, but it just looks horrible on some devices. Is there any more predictable way of accomplishing custom background and custom font on a widget? Any advice would be greatly appreciated. Thanks!</p>