什么是错的ICS霍洛对话主题? [英] What's wrong with the ICS Holo Dialog theme?

查看:154
本文介绍了什么是错的ICS霍洛对话主题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个有点古怪的问题与使用全息对话的主题( @android:款式/ Theme.Holo.Dialog )的活动冰淇淋三明治

I've come across a bit of a weird issue with activities using the Holo Dialog theme (@android:style/Theme.Holo.Dialog) in Ice Cream Sandwich.

这似乎是他们忽略了自己的布局和填充整个屏幕,而不是从他们的XML布局布局的宽度和高度。同样的布局,正在为预期的蜂窝,但不能在冰淇淋三明治。

It seems like they ignore their layouts and fill the entire screen instead of the layout width and height from their XML layouts. The same layouts are working as expecting in Honeycomb, but not on Ice Cream Sandwich.

示例:

正确的方法(蜂巢)

The correct way (Honeycomb)

不正确的方式(冰淇淋三明治)

The incorrect way (Ice Cream Sandwich)

这两种设备所运行的应用程序的版本完全相同,并且正在使用的精确相同的布局。这里是有问题的布局:

Both devices are running the exact same version of the application, and are using the exact same layout. Here's the layout in question:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="940dp"
    android:layout_height="600dp"
    android:layout_margin="10dp" >

    <GridView
        android:id="@+id/gridView1"
        android:layout_width="940dp"
        android:layout_height="600dp"
        android:horizontalSpacing="10dp"
        android:numColumns="3"
        android:smoothScrollbar="true"
        android:stretchMode="columnWidth"
        android:verticalSpacing="10dp" >
    </GridView>

</LinearLayout>

任何想法,这可怎么解决?出现类似的问题在我的ICS-基于Galaxy Nexus的,而完全忽略了 match_parent 标签的高度和宽度。在ICS是对话框主题坏了吗?

Any ideas to how this can be solved? A similar issue occurs on my ICS-based Galaxy Nexus, which completely ignore the match_parent tag for height and width. Is the dialog theme broken in ICS?

更新:

我已经做了一些更多的测试,它似乎像宽度或多或少会产生正确的样子894dp,但如果我设置宽度为895dp以上,这将是不正确的样子。仿真器的作用一样。这是非常奇怪的......

I've done some more testing, and it seems like 894dp of width or less will produce the "correct" look, but if I set the width to 895dp or more, it'll be the incorrect look. The emulator's acting the same way. This is extremely weird...

推荐答案

我不认为这是真的,ICS鼓励对话。事实上,他们已经在Android的设计整体页面。什么是真正的是 DialogFragment (这是即使在的Android支持库)是pferred超过传统的Dialog

I don't think it is true that ICS discourages dialogs. Indeed, they have a whole page at Android Design. What is true is that DialogFragment (which is even provided in the Android Support library) is preferred over the legacy Dialog.

我证实你的观察有关该对话框大跌眼镜为全屏,但是行为是依赖于设备的。在我的Xoom平板电脑它发生在915dp,而不是895。在我的Galaxy Nexus的,它发生在444dp。而在我的Galaxy Tab 10.1,这不会发生的。

I corroborate your observation about the dialog popping to full-screen, but the behavior is device-dependent. On my Xoom tablet it happens at 915dp, not 895. On my Galaxy Nexus, it happens at 444dp. And on my Galaxy Tab 10.1, it does not happen at all.

如果你深入到源代码,你可以看到有一个从河洛下降的小屏幕和霍洛一个对话的主题。 Dialog.FixedSize 较大的。我本来期望这是基于显示器大小,而不是版面大小,但也许我会是错误的。我会尽力找出是什么原因导致跳。

If you dig into the source, you can see that there is a Dialog theme that is descended from Holo for smaller screens and from Holo.Dialog.FixedSize for larger ones. I would have expected this to be based on display size, not layout size, but perhaps I would be mistaken. I'll try to figure out what causes the jump.

这篇关于什么是错的ICS霍洛对话主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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