gpt4 book ai didi

android - 更改默认小部件大小

转载 作者:搜寻专家 更新时间:2023-11-01 09:41:54 25 4
gpt4 key购买 nike

我正在开发 Android 屏幕小部件。默认大小(如果我将小部件从小部件列表拖放到我的主屏幕上)设置为 3x3,但我不知道在哪里可以更改它。谁能解释一下如何为另一个值设置默认值?

最佳答案

您在 appwidget-provider xml 中声明您的 Widget 的默认大小(和其他属性):

https://developer.android.com/guide/topics/appwidgets/index.html

特别是 minWidthminHeight 属性:

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth="40dp"
android:minHeight="40dp"
android:updatePeriodMillis="86400000"
android:previewImage="@drawable/preview"
android:initialLayout="@layout/example_appwidget"
android:configure="com.example.android.ExampleAppWidgetConfigure"
android:resizeMode="horizontal|vertical"
android:widgetCategory="home_screen">
</appwidget-provider>

The values for the minWidth and minHeight attributes specify the minimum amount of space the App Widget consumes by default. The default Home screen positions App Widgets in its window based on a grid of cells that have a defined height and width. If the values for an App Widget's minimum width or height don't match the dimensions of the cells, then the App Widget dimensions round up to the nearest cell size.

关于android - 更改默认小部件大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39510172/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com