网格布局:计算器页面

这篇博客介绍了如何在Android开发中运用网格布局来构建计算器页面。内容涵盖网格布局的关键属性,如rowCount、columnCount,以及如何通过layout_row、layout_column、layout_rowSpan和layout_columnSpan来设置子视图的位置和大小。还展示了最终实现的效果。
摘要由CSDN通过智能技术生成

网格布局相关属性:
布局行数和列数
rowCount:行数
columnCount:列数
单元格操作
layout_row:子控件在布局的行数
layout_column:子控件在布局的列数
layout_rowSpan:跨行数
layout_columnSpan:跨列数

效果:
在这里插入图片描述
实现:

<?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:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/bk021"
    android:gravity="center_horizontal"
    tools:context=".MainActivity">

    <GridLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:rowCount="7"
        android:columnCount="5">

        <TextView
            android:layout_width="320dp"
            android:layout_height="50dp"
            android:layout_column="0"
            android:layout_row="0"
            android:layout_columnSpan="5"
            android:gravity="right|center_vertical"
            android:background="@drawable/custom_border"
            android:paddingRight="10dp"
            android:text="0123456789"
            android:textColor="#0000ff"
            android:layout_marginTop="30dp"
            android:layout_marginBottom="30dp"
            android:textSize="25sp"/>

        <Button android:layout_width="65dp"
            android:layout_height="wrap_content"
            android:layout_row="1"
            android:layout_column=
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值