zoukankan      html  css  js  c++  java
  • Android 布局之LinearLayout

    Android 布局之LinearLayout


    1 LinearLayout简介

    LinearLayout是线程布局。它包括2个方向(android:orientation):“水平”(horizontal)和“竖值”(vertical)。


    2 LinearLayout示例

    创建一个activity,包含2组LinearLayout:一组LinearLayout中包含3个文本,文本是水平排列;另一组LinearLayout中包含3个文本,文本是竖值排列。

    layout文件

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tooRelativeLayoutls="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal" 
            >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#CC0000"
                android:text="@string/text_1" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#00CC00"
                android:text="@string/text_2" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#0000CC"
                android:text="@string/text_3" />
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" 
            >
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/text_1" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/text_2" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/text_3" />
        </LinearLayout>
    </LinearLayout>

    点击下载:源代码

    运行效果:

  • 相关阅读:
    Vue快速学习_第四节
    Vue快速学习_第三节
    Vue快速学习_第二节
    从N个元素的集合中随机取m个元素的算法实现
    Mysql加锁过程详解
    TFS 测试用例导入、导出工具
    TFS实现需求工作项自动级联保存
    Gulp自动构建Web前端程序
    Oracle PL/SQL Developer集成TFS进行团队脚本文件版本管理
    Python sphinx-build在Windows系统中生成Html文档
  • 原文地址:https://www.cnblogs.com/skywang12345/p/3154049.html
Copyright © 2011-2022 走看看