App Widget:您可以指定最小和默认大小吗? [英] App Widget: can you specify a minimum AND a default size?

查看:26
本文介绍了App Widget:您可以指定最小和默认大小吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您设计应用小部件时,您需要指定该小部件的最小宽度和高度.当用户放置一个新的小部件时,最小宽度和高度似乎转换为默认的小部件大小(以块为单位).

When you design an app widget, you specify a minimum width and height for that widget. When the user places a new widget, the minimum width and height appear to translate across to a default widget size (in terms of blocks).

换句话说,初始小部件布局似乎与指定的最小小部件大小相对应(他们可以随后调整大小).

In other words, the initial widget layout appears to correspond to the minimum widget size specified (which they can subsequently resize).

是否可以指定您希望小部件最初按照默认大小布局,同时还设置用户以后无法调整小部件大小的最小尺寸?

Is it possible to specify that you want the widget initially to be laid out according a default size, whilst also setting the minimum dimensions below which the user cannot resize the widget later?

在我的例子中,有一个我认为小部件看起来最好的尺寸,但如果用户真的想节省空间,它看起来仍然可以低于该尺寸.所以我想将默认值设置为我认为最好的值,并将最小值设置为真正的下限.

In my case, there is a size at which I think the widget looks best, but it still looks OK below that size if the user really wants to save on space. So I want to set the default at what I think looks best, and the minimum at what truly is the lower limit.

推荐答案

这是正确的 - 在您可以使用的应用小部件提供程序信息的元数据定义中

That is correct - in the metadata definition of for your app widget provider info you can use

minWidthminHeight 来定义您想要/默认/最佳的小部件尺寸和minResizeWidthminResizeHeight 定义允许的最小小部件尺寸

minWidth and minHeight to define your desired / default / best widget size and minResizeWidth and minResizeHeight to define the smallest allowed widget size

例如:

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
  android:minWidth="286.0dp"
  android:minHeight="146.0dp"
  android:resizeMode="vertical|horizontal"
  android:minResizeWidth="146.0dp"
  android:minResizeHeight="72.0dp"
/>

在这种情况下,默认大小为 4 x 2 单元格,最小大小为 2 x 1

In this case the default size is 4 x 2 cells, and the minimum size is 2 x 1

这篇关于App Widget:您可以指定最小和默认大小吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆