本文整理了Java中android.appwidget.AppWidgetHostView.getDefaultPaddingForWidget()
方法的一些代码示例,展示了AppWidgetHostView.getDefaultPaddingForWidget()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AppWidgetHostView.getDefaultPaddingForWidget()
方法的具体详情如下:
包路径:android.appwidget.AppWidgetHostView
类名称:AppWidgetHostView
方法名:getDefaultPaddingForWidget
暂无
代码示例来源:origin: WeAreFairphone/FP2-Launcher
static int[] getSpanForWidget(Context context, ComponentName component, int minWidth,
int minHeight) {
Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context, component, null);
// We want to account for the extra amount of padding that we are adding to the widget
// to ensure that it gets the full amount of space that it has requested
int requiredWidth = minWidth + padding.left + padding.right;
int requiredHeight = minHeight + padding.top + padding.bottom;
return CellLayout.rectToCell(requiredWidth, requiredHeight, null);
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
public static Bundle getDefaultOptionsForWidget(Context context, PendingAddWidgetInfo info) {
Bundle options = null;
if (Utilities.ATLEAST_JB_MR1) {
Rect rect = new Rect();
AppWidgetResizeFrame.getWidgetSizeRanges(context, info.spanX, info.spanY, rect);
Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context,
info.componentName, null);
float density = context.getResources().getDisplayMetrics().density;
int xPaddingDips = (int) ((padding.left + padding.right) / density);
int yPaddingDips = (int) ((padding.top + padding.bottom) / density);
options = new Bundle();
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
rect.left - xPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
rect.top - yPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
rect.right - xPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
rect.bottom - yPaddingDips);
}
return options;
}
}
代码示例来源:origin: enricocid/LaunchEnr
public static Bundle getDefaultOptionsForWidget(Context context, PendingAddWidgetInfo info) {
Rect rect = new Rect();
AppWidgetResizeFrame.getWidgetSizeRanges(context, info.spanX, info.spanY, rect);
Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context,
info.componentName, null);
float density = context.getResources().getDisplayMetrics().density;
int xPaddingDips = (int) ((padding.left + padding.right) / density);
int yPaddingDips = (int) ((padding.top + padding.bottom) / density);
Bundle options = new Bundle();
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
rect.left - xPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
rect.top - yPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
rect.right - xPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
rect.bottom - yPaddingDips);
return options;
}
}
代码示例来源:origin: klinker24/launcher3
public static Bundle getDefaultOptionsForWidget(Context context, PendingAddWidgetInfo info) {
Bundle options = null;
if (Utilities.ATLEAST_JB_MR1) {
Rect rect = new Rect();
AppWidgetResizeFrame.getWidgetSizeRanges(context, info.spanX, info.spanY, rect);
Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(context,
info.componentName, null);
float density = context.getResources().getDisplayMetrics().density;
int xPaddingDips = (int) ((padding.left + padding.right) / density);
int yPaddingDips = (int) ((padding.top + padding.bottom) / density);
options = new Bundle();
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
rect.left - xPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
rect.top - yPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
rect.right - xPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
rect.bottom - yPaddingDips);
}
return options;
}
}
代码示例来源:origin: WeAreFairphone/FP2-Launcher
static Bundle getDefaultOptionsForWidget(Launcher launcher, PendingAddWidgetInfo info) {
Bundle options = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
AppWidgetResizeFrame.getWidgetSizeRanges(launcher, info.spanX, info.spanY, sTmpRect);
Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(launcher,
info.componentName, null);
float density = launcher.getResources().getDisplayMetrics().density;
int xPaddingDips = (int) ((padding.left + padding.right) / density);
int yPaddingDips = (int) ((padding.top + padding.bottom) / density);
options = new Bundle();
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
sTmpRect.left - xPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
sTmpRect.top - yPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
sTmpRect.right - xPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
sTmpRect.bottom - yPaddingDips);
}
return options;
}
代码示例来源:origin: fookwood/Launcher3
public static Bundle getDefaultOptionsForWidget(Launcher launcher, PendingAddWidgetInfo info) {
Bundle options = null;
Rect rect = new Rect();
if (Utilities.ATLEAST_JB_MR1) {
AppWidgetResizeFrame.getWidgetSizeRanges(launcher, info.spanX, info.spanY, rect);
Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(launcher,
info.componentName, null);
float density = launcher.getResources().getDisplayMetrics().density;
int xPaddingDips = (int) ((padding.left + padding.right) / density);
int yPaddingDips = (int) ((padding.top + padding.bottom) / density);
options = new Bundle();
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
rect.left - xPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
rect.top - yPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
rect.right - xPaddingDips);
options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
rect.bottom - yPaddingDips);
}
return options;
}
}
代码示例来源:origin: enricocid/LaunchEnr
void initSpans(Context context) {
InvariantDeviceProfile idp = LauncherAppState.getIDP(context);
Point paddingLand = idp.landscapeProfile.getTotalWorkspacePadding();
Point paddingPort = idp.portraitProfile.getTotalWorkspacePadding();
// Always assume we're working with the smallest span to make sure we
// reserve enough space in both orientations.
float smallestCellWidth = DeviceProfile.calculateCellWidth(Math.min(
idp.landscapeProfile.widthPx - paddingLand.x,
idp.portraitProfile.widthPx - paddingPort.x),
idp.numColumns);
float smallestCellHeight = DeviceProfile.calculateCellWidth(Math.min(
idp.landscapeProfile.heightPx - paddingLand.y,
idp.portraitProfile.heightPx - paddingPort.y),
idp.numRows);
// We want to account for the extra amount of padding that we are adding to the widget
// to ensure that it gets the full amount of space that it has requested.
Rect widgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(
context, provider, null);
spanX = Math.max(1, (int) Math.ceil(
(minWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth));
spanY = Math.max(1, (int) Math.ceil(
(minHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight));
minSpanX = Math.max(1, (int) Math.ceil(
(minResizeWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth));
minSpanY = Math.max(1, (int) Math.ceil(
(minResizeHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight));
}
代码示例来源:origin: klinker24/launcher3
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
desiredWorkspaceLeftRightMarginPx = edgeMarginPx;
代码示例来源:origin: fookwood/Launcher3
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
desiredWorkspaceLeftRightMarginPx = 2 * edgeMarginPx;
代码示例来源:origin: enricocid/LaunchEnr
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
desiredWorkspaceLeftRightMarginPx = edgeMarginPx;
代码示例来源:origin: klinker24/Android-Blur-Launcher
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
desiredWorkspaceLeftRightMarginPx = edgeMarginPx;
代码示例来源:origin: fookwood/Launcher3
private void initSpans() {
LauncherAppState app = LauncherAppState.getInstance();
InvariantDeviceProfile idp = app.getInvariantDeviceProfile();
// We only care out the cell size, which is independent of the the layout direction.
Rect paddingLand = idp.landscapeProfile.getWorkspacePadding(false /* isLayoutRtl */);
Rect paddingPort = idp.portraitProfile.getWorkspacePadding(false /* isLayoutRtl */);
// Always assume we're working with the smallest span to make sure we
// reserve enough space in both orientations.
float smallestCellWidth = DeviceProfile.calculateCellWidth(Math.min(
idp.landscapeProfile.widthPx - paddingLand.left - paddingLand.right,
idp.portraitProfile.widthPx - paddingPort.left - paddingPort.right),
idp.numColumns);
float smallestCellHeight = DeviceProfile.calculateCellWidth(Math.min(
idp.landscapeProfile.heightPx - paddingLand.top - paddingLand.bottom,
idp.portraitProfile.heightPx - paddingPort.top - paddingPort.bottom),
idp.numRows);
// We want to account for the extra amount of padding that we are adding to the widget
// to ensure that it gets the full amount of space that it has requested.
Rect widgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(
app.getContext(), provider, null);
spanX = Math.max(1, (int) Math.ceil(
(minWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth));
spanY = Math.max(1, (int) Math.ceil(
(minHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight));
minSpanX = Math.max(1, (int) Math.ceil(
(minResizeWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth));
minSpanY = Math.max(1, (int) Math.ceil(
(minResizeHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight));
}
代码示例来源:origin: klinker24/launcher3
public void initSpans() {
LauncherAppState app = LauncherAppState.getInstance();
InvariantDeviceProfile idp = app.getInvariantDeviceProfile();
Point paddingLand = idp.landscapeProfile.getTotalWorkspacePadding();
Point paddingPort = idp.portraitProfile.getTotalWorkspacePadding();
// Always assume we're working with the smallest span to make sure we
// reserve enough space in both orientations.
float smallestCellWidth = DeviceProfile.calculateCellWidth(Math.min(
idp.landscapeProfile.widthPx - paddingLand.x,
idp.portraitProfile.widthPx - paddingPort.x),
idp.numColumns);
float smallestCellHeight = DeviceProfile.calculateCellWidth(Math.min(
idp.landscapeProfile.heightPx - paddingLand.y,
idp.portraitProfile.heightPx - paddingPort.y),
idp.numRows);
// We want to account for the extra amount of padding that we are adding to the widget
// to ensure that it gets the full amount of space that it has requested.
Rect widgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(
app.getContext(), provider, null);
spanX = Math.max(1, (int) Math.ceil(
(minWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth));
spanY = Math.max(1, (int) Math.ceil(
(minHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight));
minSpanX = Math.max(1, (int) Math.ceil(
(minResizeWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth));
minSpanY = Math.max(1, (int) Math.ceil(
(minResizeHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight));
}
代码示例来源:origin: klinker24/Android-Blur-Launcher
public void initSpans() {
LauncherAppState app = LauncherAppState.getInstance();
InvariantDeviceProfile idp = app.getInvariantDeviceProfile();
Point paddingLand = idp.landscapeProfile.getTotalWorkspacePadding();
Point paddingPort = idp.portraitProfile.getTotalWorkspacePadding();
// Always assume we're working with the smallest span to make sure we
// reserve enough space in both orientations.
float smallestCellWidth = DeviceProfile.calculateCellWidth(Math.min(
idp.landscapeProfile.widthPx - paddingLand.x,
idp.portraitProfile.widthPx - paddingPort.x),
idp.numColumns);
float smallestCellHeight = DeviceProfile.calculateCellWidth(Math.min(
idp.landscapeProfile.heightPx - paddingLand.y,
idp.portraitProfile.heightPx - paddingPort.y),
idp.numRows);
// We want to account for the extra amount of padding that we are adding to the widget
// to ensure that it gets the full amount of space that it has requested.
Rect widgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(
app.getContext(), provider, null);
spanX = Math.max(1, (int) Math.ceil(
(minWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth));
spanY = Math.max(1, (int) Math.ceil(
(minHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight));
minSpanX = Math.max(1, (int) Math.ceil(
(minResizeWidth + widgetPadding.left + widgetPadding.right) / smallestCellWidth));
minSpanY = Math.max(1, (int) Math.ceil(
(minResizeHeight + widgetPadding.top + widgetPadding.bottom) / smallestCellHeight));
}
代码示例来源:origin: enricocid/LaunchEnr
mWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(getContext(),
widgetView.getAppWidgetInfo().provider, null);
} else {
代码示例来源:origin: fookwood/Launcher3
mWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context,
widgetView.getAppWidgetInfo().provider, null);
} else {
代码示例来源:origin: WeAreFairphone/FP2-Launcher
addView(mBottomHandle, lp);
Rect p = AppWidgetHostView.getDefaultPaddingForWidget(context,
widgetView.getAppWidgetInfo().provider, null);
mWidgetPaddingLeft = p.left;
代码示例来源:origin: WeAreFairphone/FP2-Launcher
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
edgeMarginPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
desiredWorkspaceLeftRightMarginPx = 2 * edgeMarginPx;
代码示例来源:origin: klinker24/Android-Blur-Launcher
mWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context,
widgetView.getAppWidgetInfo().provider, null);
} else {
代码示例来源:origin: klinker24/launcher3
mWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context,
widgetView.getAppWidgetInfo().provider, null);
} else {
内容来源于网络,如有侵权,请联系作者删除!