Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 用网格布局搞乱计算器_Android_Xml_Android Layout - Fatal编程技术网

Android 用网格布局搞乱计算器

Android 用网格布局搞乱计算器,android,xml,android-layout,Android,Xml,Android Layout,我面临着让布局看起来漂亮的问题 为了了解基础知识,我决定创建一个简单的计算器应用程序。 因此,我使用嵌套在LinearLayout中的GridLayout将按钮放置在文本字段下 这是我布局的来源 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://sch

我面临着让布局看起来漂亮的问题

为了了解基础知识,我决定创建一个简单的计算器应用程序。
因此,我使用嵌套在LinearLayout中的GridLayout将按钮放置在文本字段下

这是我布局的来源

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="100">

    <TextView
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:text="0"
        android:layout_weight="30"/>

    <GridLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:columnCount="4"
        android:rowCount="5"
        android:orientation="horizontal"
        android:useDefaultMargins="false"
        android:layout_weight="70">

        <Button
            android:text="C" />

        <Button
            android:text="BS" />

        <Button
            android:text="/" />

        <Button
            android:text="x" />

        <Button
            android:text="7" />

        <Button
            android:text="8" />

        <Button
            android:text="9" />

        <Button
            android:text="-" />

        <Button
            android:text="4" />

        <Button
            android:text="5" />

        <Button
            android:text="6" />

        <Button
            android:text="+" />

        <Button
            android:text="1" />

        <Button
            android:text="2" />

        <Button
            android:text="3" />

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

</LinearLayout>

如何使此布局填充屏幕

让我的应用程序看起来像这样

希望能迅速得到答案

[编辑]:现在情况好多了,但我有了新问题。 现在我的主要活动是这样的

在我看来相当不错,但是:

  • 如何删除键盘右侧的空白
  • 如何使键盘和文本视图分别占据70%和30%的屏幕
  • 此外,新布局代码为:

    <?xml version="1.0" encoding="utf-8"?>
    
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context="android.calcandroid.MainActivity">
    
        <TextView
            android:background="@drawable/shape"
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:text="0"
            android:layout_above="@+id/gridLayout" />
    
        <GridLayout
            android:id="@+id/gridLayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_alignParentBottom="true"
            android:columnCount="4"
            android:rowCount="5"
            android:orientation="horizontal"
            android:useDefaultMargins="false">
    
            <Button
                android:background="@drawable/shape"
                android:text="C" />
    
            <Button
                android:background="@drawable/shape"
                android:text="BS" />
    
            <Button
                android:background="@drawable/shape"
                android:text="/" />
    
            <Button
                android:background="@drawable/shape"
                android:text="x" />
    
            <Button
                android:background="@drawable/shape"
                android:text="7" />
    
            <Button
                android:background="@drawable/shape"
                android:text="8" />
    
            <Button
                android:background="@drawable/shape"
                android:text="9" />
    
            <Button
                android:background="@drawable/shape"
                android:text="-" />
    
            <Button
                android:background="@drawable/shape"
                android:text="4" />
    
            <Button
                android:background="@drawable/shape"
                android:text="5" />
    
            <Button
                android:background="@drawable/shape"
                android:text="6" />
    
            <Button
                android:background="@drawable/shape"
                android:text="+" />
    
            <Button
                android:background="@drawable/shape"
                android:text="1" />
    
            <Button
                android:background="@drawable/shape"
                android:text="2" />
    
            <Button
                android:background="@drawable/shape"
                android:text="3" />
    
            <Button
                android:background="@drawable/shape"
                android:layout_gravity="fill_vertical"
                android:layout_rowSpan="2"
                android:text="=" />
            <Button
                android:background="@drawable/shape"
                android:layout_gravity="fill_horizontal"
                android:layout_columnSpan="2"
                android:text="0" />
            <Button
                android:background="@drawable/shape"
                android:text="." />
        </GridLayout>
    
    </RelativeLayout>
    

    将=和0按钮更改为:

    <Button
        android:layout_rowSpan="2"
        android:layout_gravity="fill_vertical"
        android:text="=" />
    <Button
        android:layout_columnSpan="2"
        android:layout_gravity="fill_horizontal"
        android:text="0" />
    
    
    
    [编辑]

    我从你的评论中意识到,=按钮突出到屏幕底部。这是因为您为计算器指定了较高的权重,因此使用fill_vertical可以做到这一点

    我假设(如果我错了,请纠正我)从您显示的所需图形中,您希望计算器与屏幕底部对齐。如果是这种情况,下面是我对布局的建议修改(tldr:使用RelativeLayout而不是LinearLayout):


    非常接近。不知道如何处理垂直分隔器。出于某种原因,在跨越每行的每列之间放置
    1dp
    视图会导致GridLayout展开整个视图

    要使用它,您的支持库版本需要这个依赖项

    compile "com.android.support:gridlayout-v7:<support library number>"
    
    compile“com.android.support:gridlayout-v7:
    

    color.xml

    <color name="calcAccent">#ef6c00</color>
    
    #ef6c00
    
    styles.xml

    <style name="calcAction">
        <item name="android:background">#f7f8fa</item>
    </style>
    <style name="calcNumber">
        <item name="android:background">#fafbfd</item>
    </style>
    
    
    #f7f8fa
    #fafbfd
    
    布局XML

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:grid="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
        <TextView
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:text="0"
                android:layout_above="@+id/gridLayout" android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true" android:gravity="bottom|end"
                android:singleLine="true" android:textAppearance="@style/TextAppearance.AppCompat.Headline"
                android:textSize="48sp" android:background="#e3e7ea" android:paddingBottom="32dp"
                android:padding="16dp"/>
    
        <android.support.v7.widget.GridLayout
                android:id="@+id/gridLayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true" android:layout_centerHorizontal="true"
                grid:useDefaultMargins="false" grid:alignmentMode="alignBounds" grid:columnCount="7" grid:rowCount="9">
    
            <!-- Row 1 -->
            <Button
                    android:text="C"
                    grid:layout_row="0" grid:layout_column="0"
                    style="@style/calcAction" android:textStyle="bold" android:textColor="@color/calcAccent"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"/>
            <ImageButton
                    android:src="@android:drawable/ic_input_delete"
                    grid:layout_row="0" grid:layout_column="2"
                    style="@style/calcAction"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1" />
            <Button
                    android:text="&#247;"
                    grid:layout_row="0"
                    style="@style/calcAction"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1" grid:layout_column="4"/>
            <Button
                    android:text="x"
                    grid:layout_row="0" grid:layout_column="6"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"
                    style="@style/calcAction"/>
    
            <!-- Row 2 -->
            <View
                    grid:layout_gravity="fill_horizontal"
                    android:layout_height="1dp"
                    grid:layout_row="1" grid:layout_column="0" grid:layout_columnSpan="7"
                    android:background="#eee"/>
            <Button
                    android:text="7" grid:layout_row="2" grid:layout_column="0"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"
                    style="@style/calcNumber"/>
            <Button
                    android:text="8" grid:layout_row="2" grid:layout_column="2"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"/>
            <Button
                    android:text="9" grid:layout_row="2" grid:layout_column="4"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"/>
            <Button
                    android:text="-" grid:layout_row="2" grid:layout_column="6"
                    style="@style/calcAction"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"/>
    
            <!-- Row 3 -->
            <View
                    grid:layout_gravity="fill_horizontal"
                    android:layout_height="1dp"
                    grid:layout_row="3" grid:layout_column="0" grid:layout_columnSpan="7"
                    android:background="#eee"/>
            <Button
                    android:text="4" grid:layout_row="4" grid:layout_column="0"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"/>
            <Button
                    android:text="5" grid:layout_row="4" grid:layout_column="2"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"/>
            <Button
                    android:text="6" grid:layout_row="4" grid:layout_column="4"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"/>
            <Button
                    android:text="+" grid:layout_row="4" grid:layout_column="6"
                    style="@style/calcAction"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"/>
    
            <View
                    grid:layout_gravity="fill_horizontal"
                    android:layout_height="1dp"
                    grid:layout_row="7" grid:layout_column="0" grid:layout_columnSpan="7"
                    android:background="#eee"/>
    
            <!-- Row 4 -->
            <Button
                    android:text="1" grid:layout_row="6" grid:layout_column="0"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"/>
            <Button
                    android:text="2" grid:layout_row="6" grid:layout_column="2"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"/>
            <Button
                    android:text="3" grid:layout_row="6" grid:layout_column="4"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"/>
            <Button
                    android:text="=" grid:layout_row="6" grid:layout_column="6"
                    style="@style/calcNumber" android:background="@color/calcAccent"
                    grid:layout_rowSpan="3"
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"
                    android:textAppearance="@style/TextAppearance.AppCompat.Large"
                    android:textColor="@color/primary_material_light" android:textStyle="bold" android:textSize="22sp"
                    android:gravity="bottom|center_horizontal" android:padding="8dp"/>
            <!-- Row 5 -->
    
            <Button
                    grid:layout_columnWeight="1" grid:layout_rowWeight="1"
                    android:text="0"
                    grid:layout_row="8" grid:layout_column="0" grid:layout_columnSpan="3"
                    style="@style/calcNumber"/>
            <Button
                    android:text="."
                    grid:layout_row="8" grid:layout_column="4"
                    grid:layout_columnWeight="1" style="@style/calcNumber"/>
    
            <!-- Horizontal Grid -->
            <View
                    grid:layout_gravity="fill_horizontal"
                    android:layout_height="1dp"
                    grid:layout_row="5" grid:layout_column="0" grid:layout_columnSpan="7"
                    android:background="#eee"/>
    
    
        </android.support.v7.widget.GridLayout>
    
    </RelativeLayout>
    

    最后,差不多十个小时后,我终于满意了。

    根据@cricket_007的建议,我的代码是

    <?xml version="1.0" encoding="utf-8"?>
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:grid="http://schemas.android.com/apk/res-auto"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="100"
        tools:context="android.calcandroid.MainActivity">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="20">
    
            <TextView
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:text="0"
                android:gravity="bottom|end"
                android:singleLine="true"
                android:textAppearance="@style/TextAppearance.AppCompat.Headline"
                android:textSize="48sp"
                android:background="#e3e7ea"
                android:paddingBottom="32dp"
                android:padding="16dp"/>
    
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="80">
    
            <android.support.v7.widget.GridLayout
                android:id="@+id/gridLayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                grid:useDefaultMargins="false"
                grid:alignmentMode="alignBounds"
                grid:columnCount="7"
                grid:rowCount="9">
    
                <!-- Row 1 -->
                <Button
                    android:text="C"
                    android:background="@drawable/shape"
                    grid:layout_row="0"
                    grid:layout_column="0"
                    style="@style/calcAction"
                    android:textStyle="bold"
                    android:textColor="@color/calcAccent"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <ImageButton
                    android:background="@drawable/shape"
                    android:src="@android:drawable/ic_input_delete"
                    grid:layout_row="0"
                    grid:layout_column="2"
                    style="@style/calcAction"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1" />
    
                <Button
                    android:background="@drawable/shape"
                    android:text="&#247;"
                    grid:layout_row="0"
                    style="@style/calcAction"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    grid:layout_column="4"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="x"
                    grid:layout_row="0"
                    grid:layout_column="6"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    style="@style/calcAction"/>
    
                <!-- Row 2 -->
                <View
                    grid:layout_gravity="fill_horizontal"
                    android:layout_height="1dp"
                    grid:layout_row="1"
                    grid:layout_column="0"
                    grid:layout_columnSpan="7"
                    android:background="#eee"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="7"
                    grid:layout_row="2"
                    grid:layout_column="0"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    style="@style/calcNumber"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="8"
                    grid:layout_row="2"
                    grid:layout_column="2"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="9"
                    grid:layout_row="2"
                    grid:layout_column="4"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="-"
                    grid:layout_row="2"
                    grid:layout_column="6"
                    style="@style/calcAction"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <!-- Row 3 -->
    
                <View
                    grid:layout_gravity="fill_horizontal"
                    android:layout_height="1dp"
                    grid:layout_row="3"
                    grid:layout_column="0"
                    grid:layout_columnSpan="7"
                    android:background="#eee"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="4"
                    grid:layout_row="4"
                    grid:layout_column="0"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="5"
                    grid:layout_row="4"
                    grid:layout_column="2"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="6"
                    grid:layout_row="4"
                    grid:layout_column="4"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="+"
                    grid:layout_row="4"
                    grid:layout_column="6"
                    style="@style/calcAction"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <View
                    grid:layout_gravity="fill_horizontal"
                    android:layout_height="1dp"
                    grid:layout_row="7"
                    grid:layout_column="0"
                    grid:layout_columnSpan="7"
                    android:background="#eee"/>
    
                <!-- Row 4 -->
    
                <Button
                    android:background="@drawable/shape"
                    android:text="1"
                    grid:layout_row="6"
                    grid:layout_column="0"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="2"
                    grid:layout_row="6"
                    grid:layout_column="2"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    grid:layout_row="6"
                    grid:layout_column="4"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    android:text="3"
                    style="@style/calcNumber"/>
    
                <Button
                    grid:layout_row="6"
                    grid:layout_column="6"
                    grid:layout_rowSpan="3"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    android:background="@color/calcAccent"
                    android:textAppearance="@style/TextAppearance.AppCompat.Large"
                    android:textColor="@color/primary_material_light"
                    android:textStyle="bold"
                    android:textSize="22sp"
                    android:gravity="center_vertical|center_horizontal"
                    android:padding="8dp"
                    android:text="="
                    style="@style/calcNumber"/>
                <!-- Row 5 -->
    
                <Button
                    android:background="@drawable/shape"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    grid:layout_row="8"
                    grid:layout_column="0"
                    grid:layout_columnSpan="3"
                    style="@style/calcNumber"
                    android:text="0"/>
    
                <Button
                    android:background="@drawable/shape"
                    grid:layout_row="8"
                    grid:layout_column="4"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    style="@style/calcNumber"
                    android:text="."/>
    
                <!-- Horizontal Grid -->
                <View
                    grid:layout_gravity="fill_horizontal"
                    android:layout_height="1dp"
                    grid:layout_row="5" grid:layout_column="0" grid:layout_columnSpan="7"
                    android:background="#eee"/>
    
    
            </android.support.v7.widget.GridLayout>
    
        </LinearLayout>
    
    </LinearLayout>
    
    
    

    可能有点凌乱,但我认为没关系。

    尝试使用表格布局。然后你可以拉伸列以适应屏幕的宽度,而网格无法做到这一点?对于计算器应用程序来说,GridView或GridLayout将是完美的。@Rotwang那么,你能告诉我,我做错了什么吗?这实际上取决于你对
    使布局看起来漂亮的期望值。
    谢谢你的回答,@ChrisWard。但在emulator上,它看起来仍然很奇怪:为什么?嗨@likeanowl,我看到了问题,我对上面的帖子进行了编辑。哇,这是Fantract!是的,我考虑过在每个按钮周围添加完整的边框,但我不想“加倍”边缘的厚度,所以我在按钮之间放置了薄视图行。
    <?xml version="1.0" encoding="utf-8"?>
    
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:grid="http://schemas.android.com/apk/res-auto"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="100"
        tools:context="android.calcandroid.MainActivity">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="20">
    
            <TextView
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                android:text="0"
                android:gravity="bottom|end"
                android:singleLine="true"
                android:textAppearance="@style/TextAppearance.AppCompat.Headline"
                android:textSize="48sp"
                android:background="#e3e7ea"
                android:paddingBottom="32dp"
                android:padding="16dp"/>
    
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="80">
    
            <android.support.v7.widget.GridLayout
                android:id="@+id/gridLayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                grid:useDefaultMargins="false"
                grid:alignmentMode="alignBounds"
                grid:columnCount="7"
                grid:rowCount="9">
    
                <!-- Row 1 -->
                <Button
                    android:text="C"
                    android:background="@drawable/shape"
                    grid:layout_row="0"
                    grid:layout_column="0"
                    style="@style/calcAction"
                    android:textStyle="bold"
                    android:textColor="@color/calcAccent"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <ImageButton
                    android:background="@drawable/shape"
                    android:src="@android:drawable/ic_input_delete"
                    grid:layout_row="0"
                    grid:layout_column="2"
                    style="@style/calcAction"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1" />
    
                <Button
                    android:background="@drawable/shape"
                    android:text="&#247;"
                    grid:layout_row="0"
                    style="@style/calcAction"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    grid:layout_column="4"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="x"
                    grid:layout_row="0"
                    grid:layout_column="6"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    style="@style/calcAction"/>
    
                <!-- Row 2 -->
                <View
                    grid:layout_gravity="fill_horizontal"
                    android:layout_height="1dp"
                    grid:layout_row="1"
                    grid:layout_column="0"
                    grid:layout_columnSpan="7"
                    android:background="#eee"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="7"
                    grid:layout_row="2"
                    grid:layout_column="0"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    style="@style/calcNumber"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="8"
                    grid:layout_row="2"
                    grid:layout_column="2"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="9"
                    grid:layout_row="2"
                    grid:layout_column="4"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="-"
                    grid:layout_row="2"
                    grid:layout_column="6"
                    style="@style/calcAction"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <!-- Row 3 -->
    
                <View
                    grid:layout_gravity="fill_horizontal"
                    android:layout_height="1dp"
                    grid:layout_row="3"
                    grid:layout_column="0"
                    grid:layout_columnSpan="7"
                    android:background="#eee"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="4"
                    grid:layout_row="4"
                    grid:layout_column="0"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="5"
                    grid:layout_row="4"
                    grid:layout_column="2"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="6"
                    grid:layout_row="4"
                    grid:layout_column="4"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="+"
                    grid:layout_row="4"
                    grid:layout_column="6"
                    style="@style/calcAction"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <View
                    grid:layout_gravity="fill_horizontal"
                    android:layout_height="1dp"
                    grid:layout_row="7"
                    grid:layout_column="0"
                    grid:layout_columnSpan="7"
                    android:background="#eee"/>
    
                <!-- Row 4 -->
    
                <Button
                    android:background="@drawable/shape"
                    android:text="1"
                    grid:layout_row="6"
                    grid:layout_column="0"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    android:text="2"
                    grid:layout_row="6"
                    grid:layout_column="2"
                    style="@style/calcNumber"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"/>
    
                <Button
                    android:background="@drawable/shape"
                    grid:layout_row="6"
                    grid:layout_column="4"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    android:text="3"
                    style="@style/calcNumber"/>
    
                <Button
                    grid:layout_row="6"
                    grid:layout_column="6"
                    grid:layout_rowSpan="3"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    android:background="@color/calcAccent"
                    android:textAppearance="@style/TextAppearance.AppCompat.Large"
                    android:textColor="@color/primary_material_light"
                    android:textStyle="bold"
                    android:textSize="22sp"
                    android:gravity="center_vertical|center_horizontal"
                    android:padding="8dp"
                    android:text="="
                    style="@style/calcNumber"/>
                <!-- Row 5 -->
    
                <Button
                    android:background="@drawable/shape"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    grid:layout_row="8"
                    grid:layout_column="0"
                    grid:layout_columnSpan="3"
                    style="@style/calcNumber"
                    android:text="0"/>
    
                <Button
                    android:background="@drawable/shape"
                    grid:layout_row="8"
                    grid:layout_column="4"
                    grid:layout_columnWeight="1"
                    grid:layout_rowWeight="1"
                    style="@style/calcNumber"
                    android:text="."/>
    
                <!-- Horizontal Grid -->
                <View
                    grid:layout_gravity="fill_horizontal"
                    android:layout_height="1dp"
                    grid:layout_row="5" grid:layout_column="0" grid:layout_columnSpan="7"
                    android:background="#eee"/>
    
    
            </android.support.v7.widget.GridLayout>
    
        </LinearLayout>
    
    </LinearLayout>