zoukankan      html  css  js  c++  java
  • Android新手之旅(10) 嵌套布局

    想在界面上放四个按钮,以2*2的形式存在,却没有办法快速实现。尝试了一下,可以用嵌套的方式,一个LinearLayout嵌套两个LinearLayout,外层的LinearLayout用纵向布局,而内部的用横向布局。

    xml文件:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/bk0">
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="180px"
            android:layout_marginLeft="60px" android:layout_marginTop="70px"
            >
            <Button android:background="@drawable/btn01"
                android:text="" android:id="@+id/button1"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                >
            </Button>
            <Button android:background="@drawable/btn02"
                android:text="" android:id="@+id/button2"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                >
            </Button>
        </LinearLayout>
        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="180px"
            android:layout_marginLeft="60px" android:layout_marginTop="0px"
            >
            <Button android:background="@drawable/btn03"
                android:text="" android:id="@+id/button3"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                >
            </Button>
            <Button android:background="@drawable/btn04"
                android:text="" android:id="@+id/button4"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                >
            </Button>
        </LinearLayout>
    </LinearLayout>

    效果:

    image

  • 相关阅读:
    HTTP 501 错误 – 未实现 (Not implemented) 或者是 Failure: Address already in use
    HTTP 400 Bad request 原因
    树莓派 NAS aria2 下载磁力链接无速度
    踩坑备忘之“yarn : 无法加载文件 C:\Users\siazon\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本。"
    架构小试之IDL
    服务端基本概念和指标
    git常用命令
    mysql20211116
    blog JavaJinguo
    android 分享功能
  • 原文地址:https://www.cnblogs.com/jetz/p/2115244.html
Copyright © 2011-2022 走看看