简体   繁体   English

Android主屏幕小部件的最大高度和宽度

[英]Android Home Screen Maximum Height&Width for widget

Is there a possible way to get the size of device's grid? 有没有办法获得设备网格的大小? (4x4 or 5x5). (4x4或5x5)。 With the code below, I can only get the dimension of the full screen. 使用下面的代码,我只能获得全屏的尺寸。 I've attached an image file for clarification. 我已附上图片文件以进行澄清。

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

在此输入图像描述

I've had an appWidget that was 1x1 cell in size. 我有一个appWidget,大小为1x1个单元格。 I set it to 72dp x 72dp, and it was working fine.. But it seems like Google changed the widget dimension sizing formula from 我把它设置为72dp x 72dp,它工作正常..但似乎谷歌改变了小部件尺寸大小公式

(cells * 74) - 2

to

(cells * 70) - 30

So now the default size of my widget has to be 40dp x 40dp.. 所以现在我的小部件的默认大小必须是40dp x 40dp ..

Source: http://developer.android.com/guide/practices/ui_guidelines/widget_design.html#anatomy_determining_size 资料来源: http//developer.android.com/guide/practices/ui_guidelines/widget_design.html#anatomy_determining_size

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM