Android AppWidgetProvider:如何解释最小/最大宽度/高度

时间:2015-04-09 21:12:42

标签: android android-appwidget appwidgetprovider

我目前正在尝试创建最初为4x1单元格的Android AppWidget,但可以由用户垂直调整大小。我创建了一个扩展AppWidgetProvider的类,并覆盖了onAppWidgetOptionsChanged()方法,以便在用户调整AppWidget大小时检查AppWidgets的最小和最大宽度和高度:

@Override public void onAppWidgetOptionsChanged(Context context, AppWidgetManager appWidgetManager, int appWidgetId, Bundle newOptions)
{
    int minimumHeight = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT);

    int maximumHeight = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT);

    int minimumWidth = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH);

    int maximumWidth = newOptions.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH);

    Log.d("TAG", "minimumHeight: " + minimumHeight + ", maximumHeight: " + maximumHeight + ", Difference: " + (maximumHeight - minimumHeight));

    Log.d("TAG", "minimumWidth: " + minimumWidth + ", maximumWidth: " + maximumWidth + ", Difference: " + (maximumWidth - minimumWidth));
}

但是,我不确定如何解释这些宽度和高度。从我最初的4x1 AppWidget,我的方法的输出是:

minimumHeight: 58, maximumHeight: 84, Difference: 26
minimumWidth: 304, maximumWidth: 408, Difference: 104

然后,如果我将AppWidget的大小调整为4x2,我的方法的输出是:

minimumHeight: 132, maximumHeight: 184, Difference: 52
minimumWidth: 304, maximumWidth: 408, Difference: 104

同样,如果我将AppWidget的大小调整为4x3,我的方法的输出是:

minimumHeight: 206, maximumHeight: 284, Difference: 78
minimumWidth: 304, maximumWidth: 408, Difference: 104

通过阅读App Widget Design Guidelines,我无法弄清楚这些数字对应的内容。

所以我的问题是:我如何解释这四个值?他们到底对应的是什么?

0 个答案:

没有答案