android线性布局作业——计算器

把计算器分为1:6,文本框为一份,剩下的为6份;再把6份分为4:2,规则的文本框为4份,不规则位2份;再把不规则的竖直分为3:1,数字为三分,符号位一份;把数字分为1:1,上面一份,下面一份;在把每一份的按钮填上去就好了。需要注意的是按比例填充按钮时要把高度设为0dp,注意竖直划分与水平划分时,

高度与宽度。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent">
   <LinearLayout
       android:layout_width="match_parent"
       android:layout_weight="1"
       android:layout_height="wrap_content">
       <TextView
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:text="  99999999"
           android:textSize="35dp"/>

   </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_weight="6"
        android:layout_height="wrap_content"
        android:orientation="vertical">
      <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_weight="4"
          android:orientation="vertical">
          <LinearLayout
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="1">
              <Button
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text10" />
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text11" />
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text12" />
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text13" />
          </LinearLayout>
          <LinearLayout
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="1">
              <Button
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_weight="1"
                  android:text="@string/text17" />
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text18" />
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text_3" />
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text15" />
          </LinearLayout>
          <LinearLayout
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="1">
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text7" />
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text_6" />
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text_9" />
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text16" />

          </LinearLayout>
          <LinearLayout
              android:layout_width="match_parent"
              android:layout_height="0dp"
              android:layout_weight="1">
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text_11" />
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text_12" />
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text_13" />
              <Button
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="1"
                  android:text="@string/text_14" />

          </LinearLayout>

      </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="2"
            android:orientation="horizontal">
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="3"
                android:orientation="vertical">
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1">
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:text="@string/text_15" />
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:text="@string/text_16" />
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:text="@string/text_17" />
                </LinearLayout>
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="0dp"
                    android:layout_weight="1">
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:text="@string/text_20" />
                    <Button
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_weight="1"
                        android:text="@string/text_21" />
                </LinearLayout>
            </LinearLayout>
            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                >
                <Button
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:text="@string/text_22" />
            </LinearLayout>
        </LinearLayout>
    </LinearLayout>

</LinearLayout>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值