diff options
author | Adam Cohen <adamcohen@google.com> | 2012-05-09 11:13:54 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2012-05-09 11:13:54 -0700 |
commit | f065c9663172094d2d79eb5f77c59d89e812437a (patch) | |
tree | b1a4a1e99948ee6a48c9bcd815e62730a4666925 /core/java | |
parent | 88f041ed312299f1d2746e570b989c336bfd97c8 (diff) | |
download | frameworks_base-f065c9663172094d2d79eb5f77c59d89e812437a.zip frameworks_base-f065c9663172094d2d79eb5f77c59d89e812437a.tar.gz frameworks_base-f065c9663172094d2d79eb5f77c59d89e812437a.tar.bz2 |
Accounting for widget padding in dips instead of pixels
Change-Id: I29c4290274f8b9fa6d9b49072d3cf37cf6f1acb8
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/appwidget/AppWidgetHostView.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/java/android/appwidget/AppWidgetHostView.java b/core/java/android/appwidget/AppWidgetHostView.java index 2ca2ae4..01b68d4 100644 --- a/core/java/android/appwidget/AppWidgetHostView.java +++ b/core/java/android/appwidget/AppWidgetHostView.java @@ -232,14 +232,15 @@ public class AppWidgetHostView extends FrameLayout { if (mInfo != null) { padding = getDefaultPaddingForWidget(mContext, mInfo.provider, padding); } + float density = getResources().getDisplayMetrics().density; - int xPadding = padding.left + padding.right; - int yPadding = padding.top + padding.bottom; + int xPaddingDips = (int) ((padding.left + padding.right) / density); + int yPaddingDips = (int) ((padding.top + padding.bottom) / density); - options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, minWidth - xPadding); - options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, minHeight - yPadding); - options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, maxWidth - xPadding); - options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, maxHeight - yPadding); + options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, minWidth - xPaddingDips); + options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, minHeight - yPaddingDips); + options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, maxWidth - xPaddingDips); + options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, maxHeight - yPaddingDips); updateAppWidgetOptions(options); } |