Android GridLayout columnCount在非Holo主题中不起作用

Android GridLayout columnCount在非Holo主题中不起作用,android,grid-layout,Android,Grid Layout,代码: 当主题在实际设备(我在Nexus5上,但我猜这不是一个特定于设备的问题)和eclipse预览上都设置为Holo时,这很好。但是,当我将活动的主题设置为其他任何内容时——无论是在eclipse预览还是在清单上,它看起来都很糟糕。截图如下: 非全息像是这样的 全息像是这样的 我不想(或者更确切地说,不能)使用Holo,因为我已经在使用新的ActionBarActivity,它需要一个Theme.Appcompat主题才能工作 我更感兴趣的是知道为什么这是GridLayout的行为,而

代码:


当主题在实际设备(我在Nexus5上,但我猜这不是一个特定于设备的问题)和eclipse预览上都设置为Holo时,这很好。但是,当我将活动的主题设置为其他任何内容时——无论是在eclipse预览还是在清单上,它看起来都很糟糕。截图如下:

非全息像是这样的 全息像是这样的

我不想(或者更确切地说,不能)使用Holo,因为我已经在使用新的ActionBarActivity,它需要一个Theme.Appcompat主题才能工作

我更感兴趣的是知道为什么这是GridLayout的行为,而不是Holo的可能解决方法

其他信息:

在Holo主题中,当我增加GridLayout的columnCount时,单元格宽度会适当调整。在其他主题中,它们只是从屏幕上延伸出来


我已经在实际设备上进行了测试。与预览模式完全相同。

表格布局
表格行
一起用于布局。它工作得很好

表格布局
表格行
一起用于布局。它工作得很好

看起来即使是全息主题,你也有同样的问题。看看其他屏幕尺寸。尝试设置按钮的宽度…?更好地使用
TableLayout
@ElefantPhace您是建议我为按钮设置一个固定的宽度,还是某种填充/环绕内容设置?也许可以用一些屏幕宽度和列数的编程技巧来解决这个问题,但我认为这违背了GridLayout的目的。看起来,即使是holo主题,你也有同样的问题。看看其他屏幕尺寸。尝试设置按钮的宽度…?更好地使用
TableLayout
@ElefantPhace您是建议我为按钮设置一个固定的宽度,还是某种填充/环绕内容设置?也许可以用一些屏幕宽度与列数的编程技巧来解决这个问题,但我认为这违背了GridLayout的目的。你认为我应该如何实现equals按钮(参考屏幕截图)跨越两行?您不能通过表格布局实现equal您认为我应该如何实现跨越两行的equals按钮(参考屏幕截图)?您不能通过表格布局实现equal
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.calculatorsample.MainActivity$PlaceholderFragment" >

<EditText
    style="@android:style/TextAppearance.DeviceDefault.Large"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    android:enabled="false"
    android:padding="@dimen/activity_vertical_margin" />

<GridLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:columnCount="5"
    android:orientation="horizontal" >

    <Button android:text="&lt;-" >
    </Button>

    <Button android:text="CE" >
    </Button>

    <Button android:text="C" >
    </Button>

    <Button android:text="+/-" >
    </Button>

    <Button android:text="√" >
    </Button>

    <Button android:text="7" />

    <Button android:text="8" />

    <Button android:text="9" />

    <Button android:text="/" />

    <Button android:text="%" />

    <Button android:text="4" />

    <Button android:text="5" />

    <Button android:text="6" />

    <Button android:text="*" />

    <Button android:text="1/x" />

    <Button android:text="1" />

    <Button android:text="2" />

    <Button android:text="3" />

    <Button android:text="-" />

    <Button
        android:layout_gravity="fill"
        android:layout_rowSpan="2"
        android:text="=" />

    <Button
        android:layout_columnSpan="2"
        android:layout_gravity="fill"
        android:text="0" />

    <Button android:text="." />

    <Button android:text="+" />
</GridLayout>