最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

android LinearLayout 布局實例代碼

 更新時間:2013年04月25日 11:12:55   作者:  
android LinearLayout 布局實例代碼,需要的朋友可以參考一下

復(fù)制代碼 代碼如下:

<?xml version="1.0" encoding="utf-8"?> 
<!--  
   <LinearLayout> 
       線性版面配置,在這個標(biāo)簽中,所有元件都是按由上到下的排隊排成的 
 -->
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"> 
   <!-- android:orientation="vertical" 表示豎直方式對齊 
        android:orientation="horizontal"表示水平方式對齊 
        android:layout_width="fill_parent"定義當(dāng)前視圖在屏幕上 
                     可以消費的寬度,fill_parent即填充整個屏幕。 
        android:layout_height="wrap_content":隨著文字欄位的不同 
        而改變這個視圖的寬度或者高度。有點自動設(shè)置框度或者高度的意思 

       layout_weight 用于給一個線性布局中的諸多視圖的重要度賦值。 
     所有的視圖都有一個layout_weight值,默認(rèn)為零,意思是需要顯示 
     多大的視圖就占據(jù)多大的屏幕空 間。若賦一個高于零的值,則將父視 
     圖中的可用空間分割,分割大小具體取決于每一個視圖的layout_weight 
       值以及該值在當(dāng)前屏幕布局的整體 layout_weight值和在其它視圖屏幕布 
     局的layout_weight值中所占的比率而定。 
     舉個例子:比如說我們在 水平方向上有一個文本標(biāo)簽和兩個文本編輯元素。 
    該文本標(biāo)簽并無指定layout_weight值,所以它將占據(jù)需要提供的最少空間。 
    如果兩個文本編輯元素每一個的layout_weight值都設(shè)置為1,則兩者平分 
    在父視圖布局剩余的寬度(因為我們聲明這兩者的重要度相等)。如果兩個  
   文本編輯元素其中第一個的layout_weight值設(shè)置為1,而第二個的設(shè)置為2, 
   則剩余空間的三分之二分給第一個,三分之一分給第二個(數(shù)值越小,重要 
              度越高)。 
    -->
    <LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"> 
    <TextView
        android:text="red"
        android:gravity="center_horizontal"
        android:background="#aa0000"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_weight="1"/> 

    <TextView
        android:text="green"
        android:gravity="center_horizontal"
        android:background="#00aa00"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_weight="1"/> 

    <TextView
        android:text="blue"
        android:gravity="center_horizontal"
        android:background="#0000aa"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_weight="1"/> 

    <TextView
        android:text="yellow"
        android:gravity="center_horizontal"
        android:background="#aaaa00"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_weight="1"/> 

    </LinearLayout> 

    <LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="2"> 

    <TextView
        android:text="row one"
        android:textSize="15pt"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"/> 

    <TextView
        android:text="row two"
        android:textSize="15pt"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"/> 

    <TextView
        android:text="row three"
        android:textSize="15pt"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"/> 

    <TextView
        android:text="row four"
        android:textSize="15pt"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"/> 

    </LinearLayout> 

</LinearLayout>

感覺這種形式有點像div+css的方式布局,不過這種方式的靈活性和div+css還是有些不及,主要是那android:layout_weight的值如何去確定,而且采用的是數(shù)值越小,重要度越高的方式,分配起來還得好好計算一下。

Java代碼  Views.java

復(fù)制代碼 代碼如下:

package com.cn.view; 

import android.app.Activity; 
import android.os.Bundle; 

public class Views extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.main); 
    } 
}

相關(guān)文章

  • android簡單自定義View實現(xiàn)五子棋

    android簡單自定義View實現(xiàn)五子棋

    這篇文章主要為大家詳細(xì)介紹了android簡單自定義View實現(xiàn)五子棋,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-11-11
  • Android仿微博加載長圖滾動查看效果

    Android仿微博加載長圖滾動查看效果

    這篇文章主要為大家詳細(xì)介紹了Android仿微博加載長圖滾動查看效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • Android Material加載進度條制作代碼

    Android Material加載進度條制作代碼

    這篇文章主要為大家詳細(xì)介紹了AndroidMaterial加載進度條的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • Android Studio 下 Flutter 開發(fā)環(huán)境搭建過程

    Android Studio 下 Flutter 開發(fā)環(huán)境搭建過程

    這篇文章主要介紹了Android Studio 下 Flutter 開發(fā)環(huán)境搭建/Flutter / Dart 插件安裝 | Flutter SDK 安裝 | 環(huán)境變量配置 | 開發(fā)環(huán)境檢查,本文圖文并茂給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2020-03-03
  • android studio安裝時 AVD出現(xiàn)問題如何快速解決

    android studio安裝時 AVD出現(xiàn)問題如何快速解決

    這篇文章主要介紹了安裝android studio時 AVD出現(xiàn)問題如何快速處理,其實解決方法也很簡單,文中通過截圖的形式給大家及時的非常詳細(xì),對大家的工作或?qū)W習(xí)具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-03-03
  • Flutter中如何加載并預(yù)覽本地的html文件的方法

    Flutter中如何加載并預(yù)覽本地的html文件的方法

    這篇文章主要介紹了Flutter中如何加載并預(yù)覽本地的html文件的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • Android SlidingDrawer 抽屜效果的實現(xiàn)

    Android SlidingDrawer 抽屜效果的實現(xiàn)

    本篇文章小編為大家介紹,Android SlidingDrawer 抽屜效果的實現(xiàn)。需要的朋友參考下
    2013-04-04
  • Android EditText長按菜單中分享功能的隱藏方法

    Android EditText長按菜單中分享功能的隱藏方法

    Android EditText控件是經(jīng)常使用的控件,下面這篇文章主要給大家介紹了關(guān)于Android中EditText長按菜單中分享功能的隱藏方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-02-02
  • Android自定義UI手勢密碼改進版

    Android自定義UI手勢密碼改進版

    這篇文章主要為大家詳細(xì)介紹了改進版的Android自定義UI手勢密碼功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • android開發(fā)教程之用命令啟動android模擬器并設(shè)置其內(nèi)存大小

    android開發(fā)教程之用命令啟動android模擬器并設(shè)置其內(nèi)存大小

    用命令啟動android模擬器并設(shè)置其內(nèi)存大小的方法,,需要的朋友可以參考下
    2014-02-02

最新評論

普安县| 镶黄旗| 兴义市| 桦川县| 城口县| 云南省| 石狮市| 天门市| 建宁县| 历史| 商洛市| 武定县| 夏津县| 徐水县| 大足县| 金秀| 云南省| 宁安市| 双流县| 兴和县| 灵山县| 碌曲县| 浑源县| 禹州市| 泸定县| 天柱县| 望谟县| 白银市| 壶关县| 聊城市| 景德镇市| 兰西县| 利辛县| 宁德市| 南川市| 东兴市| 郯城县| 比如县| 德令哈市| 固始县| 余姚市|