我目前正在尝试创建一个最初为 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,我无法弄清楚这些数字对应于什么。
所以我的问题是:我如何解释这四个值?它们具体对应的是什么?