Android GridLayout cutting off

1.2k views Asked by At

I'm following this tutorial: http://code.tutsplus.com/tutorials/android-user-interface-design-creating-a-numeric-keypad-with-gridlayout--mobile-8677

But in my application, I'm getting the result: enter image description here

I mean, the buttons are being cutted off of the screen.

The XML is:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="0dp"
    android:orientation="vertical"
    tools:context=".AtividadePrincipal">

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

        <Button
            android:layout_column="3"
            android:text="/" />

        <Button android:text="1" />

        <Button android:text="2" />

        <Button android:text="3" />

        <Button android:text="*" />

        <Button android:text="4" />

        <Button android:text="5" />

        <Button android:text="6" />

        <Button android:text="-" />

        <Button android:text="7" />

        <Button android:text="8" />

        <Button android:text="9" />

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

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

        <Button android:text="00" />

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

    </GridLayout>

</LinearLayout>
1

There are 1 answers

0
YETI On

android:layout_width="0dp" android:layout_height="wrap_content"

<android.support.v7.widget.GridLayout>
    ......
    <Spinner
        android:id="@+id/area"
        style="@style/Widget.AppCompat.Spinner.Underlined"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:minHeight="32dp"
        android:prompt="@null"
        app:layout_column="1"
        app:layout_gravity="center_vertical|fill_horizontal"
        app:layout_row="2" />
</android.support.v7.widget.GridLayout>

`