网格布局显示不正确

时间:2017-02-07 10:42:16

标签: android android-layout

我正在尝试构建一个简单的Android应用。 在模拟器上,网格完美地显示按钮,但是当将应用程序安装到我的移动设备时,网格看起来很糟糕 以下是XML文件:

database.child(Table).
         orderByChild("user/id")
        .equalTo("somevalue").

this how shown in mobile

this how shown in emulator

1 个答案:

答案 0 :(得分:1)

您可以在不使用<GridLayout>

的情况下达到预期目标
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin">

<LinearLayout
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="0dp">
        <Button
            android:text="Good Morning"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:onClick="Buttontapped"
            android:id="@+id/goodmorning" />
        <Button
            android:text="Good Evening"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:onClick="Buttontapped"
            android:id="@+id/goodevening" />
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="0dp">
        <Button
            android:text="Good Bye"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:onClick="Buttontapped"
            android:id="@+id/goodbye" />
        <Button
            android:text="HI / Bye"
            android:id="@+id/hibye"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:onClick="Buttontapped"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="0dp">
        <Button
            android:text="Please"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:onClick="Buttontapped"
            android:id="@+id/please" />
        <Button
            android:text="Thank You &#10; Very Much"
            android:id="@+id/thankyou"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:onClick="Buttontapped"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="0dp">

        <Button
            android:text="Welcome"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:onClick="Buttontapped"
            android:id="@+id/welcome" />
        <Button
            android:text="How are you?"
            android:id="@+id/howareyou"
            android:layout_width="0dp"
            android:layout_weight="1"
            android:layout_height="match_parent"
            android:onClick="Buttontapped"/>
    </LinearLayout>
</LinearLayout>