国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術(shù)|正則表達(dá)式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務(wù)器之家 - 編程語言 - Android - android LinearLayout 布局實(shí)例代碼

android LinearLayout 布局實(shí)例代碼

2021-01-12 15:07Android開發(fā)網(wǎng) Android

android LinearLayout 布局實(shí)例代碼,需要的朋友可以參考一下

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


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

       layout_weight 用于給一個(gè)線性布局中的諸多視圖的重要度賦值。 
     所有的視圖都有一個(gè)layout_weight值,默認(rèn)為零,意思是需要顯示 
     多大的視圖就占據(jù)多大的屏幕空 間。若賦一個(gè)高于零的值,則將父視 
     圖中的可用空間分割,分割大小具體取決于每一個(gè)視圖的layout_weight 
       值以及該值在當(dāng)前屏幕布局的整體 layout_weight值和在其它視圖屏幕布 
     局的layout_weight值中所占的比率而定。 
     舉個(gè)例子:比如說我們?cè)?水平方向上有一個(gè)文本標(biāo)簽和兩個(gè)文本編輯元素。 
    該文本標(biāo)簽并無指定layout_weight值,所以它將占據(jù)需要提供的最少空間。 
    如果兩個(gè)文本編輯元素每一個(gè)的layout_weight值都設(shè)置為1,則兩者平分 
    在父視圖布局剩余的寬度(因?yàn)槲覀兟暶鬟@兩者的重要度相等)。如果兩個(gè)  
   文本編輯元素其中第一個(gè)的layout_weight值設(shè)置為1,而第二個(gè)的設(shè)置為2, 
   則剩余空間的三分之二分給第一個(gè),三分之一分給第二個(gè)(數(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>

 

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

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); 
    } 
}

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 精品视频成人 | 狠狠人人| 久久国产成人 | 伊人久久综合 | 午夜精品成人一区二区 | 91亚洲精品在线 | 日韩在线观看成人 | 欧洲亚洲一区 | 欧美一级二级视频 | 在线欧美日韩 | 中文字幕亚洲欧美日韩在线不卡 | 国产成人精品一区二区三区视频 | 日韩欧美在线一区 | 久久久久久久久久久免费 | 久久亚洲天堂 | 久在线视频 | 亚洲 欧美 另类 综合 偷拍 | 亚洲夜幕久久日韩精品一区 | 日韩一区二区在线观看 | 91午夜在线 | 懂色av中文字幕一区二区三区 | 互换娇妻呻吟hd中文字幕 | 嫩草视频免费在线观看 | 亚洲视频自拍 | 中文字幕成人影院 | 色成人亚洲www78ixcom | 色综合天天天天做夜夜夜夜做 | 亚洲国产精品久久久久婷婷老年 | 日本中文字幕在线看 | 成人精品一区二区三区视频播放 | 激情毛片| 亚洲国产精品激情在线观看 | 亚洲综合在线视频 | 亚洲精品一二区 | 一本大道久久精品 | 福利国产 | 亚洲精品视频在线观看免费视频 | 日韩精品视频在线 | 国产精品久久久久久久久久久免费看 | 久久久久久高清 | 91亚洲精品在线 |