在网格布局Android的按键没有同样幅度最高 [英] Android Button in Gridlayout don't have same margin top

查看:264
本文介绍了在网格布局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>

这篇关于在网格布局Android的按键没有同样幅度最高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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