在网格布局Android的按键没有同样幅度最高

在网格布局Android的按键没有同样幅度最高

问题描述:

我有一个GridLayout的,而且会有在布局两个或更多个按钮,并且所有的按钮必须用相同的宽度。
我的问题是,当具有文本的不同的行号的按钮,按钮的marginTop将不同。
我该如何解决这个问题?
谢谢你。

I got a GridLayout, and there will be two or more buttons in the layout, and all the buttons must with same width. My problem is that when the buttons having different line number of text, the marginTop of button will different too. How can I fix this? Thanks.

<GridLayout
    android:id="@+id/grid_buddies"
    android:columnCount="4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
        android:layout_width="60dp"
        android:layout_height="match_parent"
        android:text="TEST"/>
    <Button
        android:layout_width="60dp"
        android:layout_height="wrap_content"
        android:text="TESTDDFF"/>
</GridLayout>

下面是图片:

使用的android:layout_gravity =fill_vertical在你的按钮属性的文字 TEST

Use android:layout_gravity="fill_vertical" attribute in your Button with text TEST

<GridLayout
    android:id="@+id/grid_buddies"
    android:columnCount="4"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <Button
       android:layout_width="60dp"
       android:layout_height="match_parent"
       android:text="TEST"
       android:layout_gravity="fill_vertical"/>
    <Button
       android:layout_width="60dp"
       android:layout_height="wrap_content"
       android:text="TESTDDFF"/>
</GridLayout>