前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Android布局练习—计算器

Android布局练习—计算器

作者头像
用户1515472
发布2019-07-24 14:15:18
7940
发布2019-07-24 14:15:18
举报

小菜鸟布局第一次布局,orz

代码语言:javascript
复制
<RelativeLayout android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TableLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_alignParentBottom="true"
        android:stretchColumns="*">
        <TextView android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:text="0"
            android:gravity="right|center_vertical"/>
        <TableRow android:id="@+id/tableRow1"
            android:layout_width="wrap_content"
            android:layout_height="80dp">
            <Button android:id="@+id/button1"
                android:layout_height="80dp"
                android:layout_width="wrap_content"
                android:text="7"
                android:background="#0a89b6"
                android:layout_marginRight="1dp"/>
            <Button android:id="@+id/button2"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:text="8"
                android:background="#0a89b6"
                android:layout_marginRight="1dp"/>
            <Button android:id="@+id/button3"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:text="9"
                android:background="#0a89b6"
                android:layout_marginRight="1dp"/>
            <Button android:id="@+id/button4"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:text="/"
                android:background="#db8122"
                />
        </TableRow>
        <TableRow android:id="@+id/tableRow2"
            android:layout_height="80dp"
            android:layout_width="wrap_content"
            android:layout_marginTop="1dp">
            <Button android:id="@+id/button5"
                android:layout_height="80dp"
                android:layout_width="wrap_content"
                android:text="4"
                android:background="#0a89b6"
                android:layout_marginRight="1dp"/>
            <Button android:id="@+id/button6"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:text="5"
                android:background="#0a89b6"
                android:layout_marginRight="1dp"/>
            <Button android:id="@+id/button7"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:text="6"
                android:background="#0a89b6"
                android:layout_marginRight="1dp"/>
            <Button android:id="@+id/button8"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:text="*"
                android:background="#db8122" />
        </TableRow>
        <TableRow android:id="@+id/tableRow3"
            android:layout_height="80dp"
            android:layout_width="wrap_content"
            android:layout_marginTop="1dp">
            <Button android:id="@+id/button9"
                android:layout_height="80dp"
                android:layout_width="wrap_content"
                android:text="1"
                android:background="#0a89b6"
                android:layout_marginRight="1dp"/>
            <Button android:id="@+id/button10"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:text="2"
                android:background="#0a89b6"
                android:layout_marginRight="1dp"/>
            <Button android:id="@+id/button11"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:text="3"
                android:background="#0a89b6"
                android:layout_marginRight="1dp"/>
            <Button android:id="@+id/button12"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:text="-"
                android:background="#db8122"/>
        </TableRow>
        <TableRow android:id="@+id/tableRow4"
            android:layout_height="80dp"
            android:layout_width="wrap_content"
            android:layout_marginTop="1dp">
            <Button android:id="@+id/button13"
                android:layout_height="80dp"
                android:layout_width="wrap_content"
                android:text="0"
                android:background="#0a89b6"
                android:layout_marginRight="1dp"/>
            <Button android:id="@+id/button14"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:text="."
                android:background="#0a89b6"
                android:layout_marginRight="1dp"/>
            <Button android:id="@+id/button15"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:text="+"
                android:background="#0a89b6"
                android:layout_marginRight="1dp"/>
            <Button android:id="@+id/button16"
                android:layout_height="match_parent"
                android:layout_width="wrap_content"
                android:text="="
                android:background="#db8122"
                android:/>
        </TableRow>

    </TableLayout>
</RelativeLayout>

截图:

screenshot_2017-09-03-18-30-46-155_com example hu
screenshot_2017-09-03-18-30-46-155_com example hu
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档