安卓:控件花费太多的地方 [英] Android: Widget takes too much place

查看:100
本文介绍了安卓:控件花费太多的地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我面临着与我的部件尺寸一个奇怪的问题。
我决定开发一个简单的小部件LDPI,MDPI,大MDPI和HDPI屏幕支持。
起初,我创造,我定义了以下XML / widget.xml:

I faced with a strange problem with my widget size. I decided to develop one simple widget with supporting of ldpi, mdpi, large-mdpi and hdpi screens. At first I created xml/widget.xml where I defined the following:

<appwidget-provider 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:minHeight="146dip" 
    android:minWidth="220dip" 
    android:updatePeriodMillis="0" 
    android:initialLayout="@layout/widget"/>

因此​​,我希望我的小部件将采取3x2的细胞对所有支持的屏幕。
然后,我设计了几个版面,每个屏幕类型 - LDPI,MDPI,大MDPI和华电国际 - 其中:

So I expect that my widget will take 3x2 cells for all supported screens. Then I designed several layouts, one for each screen type - ldpi, mdpi, large-mdpi and hdpi - where:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/Widget" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    ... 
</RelativeLayout>

于是,我想到的是,小部件的大小适合的3x2细胞所有屏幕,而不是更多,而不是更少。
但目前当我在模拟器中运行它(和真实的设备太)我看到我的小部件需要
以上为所有支持屏幕半个屏幕的 - 4x3的细胞,如果
交谈的最大尺寸为4×4电池(因为它说明如下:
http://developer.android.com/guide/practices/ui_guidelines/widget_design.html#sizes).
即使我将定义在我的窗口小部件精确layout_width和layout_height
在浸布局还是会采取4x3的细胞,只是它的可见部分
将有其他尺寸。

So I expect that the widget size will fit 3x2 cells for all screens, not more, not less. But currently when I run it on emulator (and real device too) I see that my widget takes more than a half of a screen for all supporting screens - 4x3 cells if to talk that the max size is 4x4 cells (as it described here: http://developer.android.com/guide/practices/ui_guidelines/widget_design.html#sizes). Even if I'll define exact layout_width and layout_height in my widget layouts in dip it will still take 4x3 cells, just it's visible part will have another size.

推荐答案

好吧,看起来像模拟器并不总是刷新我的应用程序,这就是为什么我看到我的老维度,而不是新的。我的朋友也说,平时模拟器如果使用的startActivityForResult不更新应用程序。因此,在这种情况下,最好是小部件手动重启。希望这将是有益别人:)

Well, looks like emulator not always refresh my app and that is why I saw my old dimensions instead of new. My friend also said that emulator usually doesn't update apps if using startActivityForResult. So in that case it is better to restart widget manually. Hope that will be helpfull for someone else :)

这篇关于安卓:控件花费太多的地方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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