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

    LinearLayout是Android中最经常使用的布局之中的一个。它将自己包括的子元素依照一个方向进行排列。方向有两种,水平或者竖直。这个方向能够通过设置android:orientation="vertical"或者android:orientation="horizontal"来实现。全部的元素排列都是一个接着一个的。假设是竖直排列,那么LinearLayout的元素就一个接着一个的从上到下竖直排列,比如,在以下的样例中。MainActivity的视图就是这样竖直的一个一个接着排列的。

    假设是水平排列,那么就是LinearLayout里边的子元素从左到右一个一个的进行排列。


    实例:LayoutDemo

    执行效果:


    代码清单:

    布局文件:main.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"
        >
        <Button
            android:id="@+id/button1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="RelativeLayout的使用" 
        />
        <Button
            android:id="@+id/button2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="FrameLayout的使用" 
        />
        <Button
            android:id="@+id/button3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:text="TableLayout的使用" 
        />
    </LinearLayout>

    Java源码文件:MainActivity.java

    package com.rainsong.layoutdemo;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    public class MainActivity extends Activity
    {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        }
    }
    


  • 相关阅读:
    PHP中each与list用法分析
    三大范式通俗讲解
    数据库三大范式详解
    利用JS制作简便计算器
    CSS下拉列表错误纠正
    下拉列表
    CSS选择器、标签,div的位置。
    php注册审核
    php分页查询
    php投票练习
  • 原文地址:https://www.cnblogs.com/blfshiye/p/5403307.html
Copyright © 2011-2022 走看看