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

Android編程之線性布局LinearLayout實(shí)例簡析

 更新時間:2016年01月06日 15:11:23   作者:jzp12  
這篇文章主要介紹了Android編程之線性布局LinearLayout用法,結(jié)合實(shí)例形式簡單分析了Android線性布局的使用技巧,需要的朋友可以參考下

本文實(shí)例講述了Android編程之線性布局LinearLayout用法。分享給大家供大家參考,具體如下:

線性布局(LinearLayout)

可以讓它的子元素垂直或水平的方式排成一行(不設(shè)置方向的時候默認(rèn)按照垂直方向排列)。

下面示例是在別人基礎(chǔ)上修改的main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical" >
  <LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:baselineAligned="false"
    android:layout_weight="1" >
    <LinearLayout
      android:orientation="horizontal"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:layout_weight="1">
      <TextView
        android:text="@string/color_green"
        android:textColor="#ff0000"
        android:background="#00aa00"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_weight="1"/>
      <TextView
        android:text="@string/color_blue"
        android:background="#0000aa"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_weight="1"/>
    </LinearLayout>
    <LinearLayout
       android:orientation="vertical"
       android:layout_width="wrap_content"
       android:layout_height="fill_parent"
       android:layout_weight="1">
       <TextView
         android:text="@string/color_black"
         android:background="#000000"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_weight="1"/>
       <TextView
         android:text="@string/color_yellow"
         android:background="#aaaa00"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_weight="1"/>
       <TextView
         android:text="@string/color_unknown"
         android:background="#00aaaa"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_weight="1"/>
     </LinearLayout>
  </LinearLayout>
  <LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="2">
    <TextView
      android:text="@string/color_red"
      android:gravity="fill_vertical"
      android:background="#aa0000"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="2"/>
    <TextView
      android:text="@string/color_white"
      android:textColor="#ff0000"
      android:background="#ffffff"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="2"/>
  </LinearLayout>
</LinearLayout>

string.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <string name="hello">Hello World, TestAbsoluteLayoutActivity!</string>
  <string name="app_name">TestAbsoluteLayout</string>
  <string name= "color_red">red</string>
  <string name= "color_green">green</string>
  <string name= "color_blue">blue</string>
  <string name= "color_white">white</string>
  <string name= "color_black">black</string>
  <string name= "color_yellow">yellow</string>
  <string name= "color_unknown">unknown</string>
</resources>

效果圖如下:

常用的屬性:

android:orientation:可以設(shè)置布局的方向
android:gravity:用來控制組件的對齊方式
layout_weight:控制各個組件在布局中的相對大小

更多關(guān)于Android編程布局相關(guān)內(nèi)容可查看本站專題:《Android布局layout技巧總結(jié)

希望本文所述對大家Android程序設(shè)計有所幫助。

相關(guān)文章

  • Json 生成與解析詳解及實(shí)例代碼

    Json 生成與解析詳解及實(shí)例代碼

    這篇文章主要介紹了Json 生成與解析詳解及實(shí)例代碼的相關(guān)資料,這里附簡單實(shí)例幫助大家學(xué)習(xí)理解,需要的朋友可以參考下
    2016-11-11
  • Android解析服務(wù)器端發(fā)來的xml數(shù)據(jù)示例

    Android解析服務(wù)器端發(fā)來的xml數(shù)據(jù)示例

    Android跟服務(wù)器交互數(shù)據(jù),有時數(shù)據(jù)量大時,就需要以xml形式的交互數(shù)據(jù),下面與大家分享下使用XmlPullParser來解析xml數(shù)據(jù),感興趣的朋友可以參考下哈
    2013-06-06
  • Android 中使用 dlib+opencv 實(shí)現(xiàn)動態(tài)人臉檢測功能

    Android 中使用 dlib+opencv 實(shí)現(xiàn)動態(tài)人臉檢測功能

    完成 Android 相機(jī)預(yù)覽功能以后,在此基礎(chǔ)上我使用 dlib 與 opencv 庫做了一個關(guān)于人臉檢測的 demo。接下來通過本文給大家介紹Android 中使用 dlib+opencv 實(shí)現(xiàn)動態(tài)人臉檢測功能 ,需要的朋友可以參考下
    2018-11-11
  • Android屬性動畫實(shí)現(xiàn)炫酷的登錄界面

    Android屬性動畫實(shí)現(xiàn)炫酷的登錄界面

    這篇文章主要為大家詳細(xì)介紹了Android屬性動畫實(shí)現(xiàn)炫酷的登錄界面,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-07-07
  • 詳細(xì)分析Android-Zygote的啟動過程

    詳細(xì)分析Android-Zygote的啟動過程

    在Android系統(tǒng)中,所有的應(yīng)用程序進(jìn)程以及系統(tǒng)服務(wù)進(jìn)程SystemServer都是由Zygote進(jìn)程孕育(fork)出來的,這也許就是為什么要把它稱為Zygote(受精卵)的原因吧。由于Zygote進(jìn)程在Android系統(tǒng)中有著如此重要的地位,本文將詳細(xì)分析它的啟動過程
    2021-06-06
  • Android6.0仿微信權(quán)限設(shè)置

    Android6.0仿微信權(quán)限設(shè)置

    這篇文章主要為大家詳細(xì)介紹了Android6.0仿微信權(quán)限設(shè)置的相關(guān)內(nèi)容,感興趣的小伙伴們可以參考一下
    2016-08-08
  • Android 使用Fragment模仿微信界面的實(shí)例代碼

    Android 使用Fragment模仿微信界面的實(shí)例代碼

    自從Android 3.0中引入fragments 的概念,根據(jù)詞海的翻譯可以譯為:碎片、片段。其目的是為了解決不同屏幕分辯率的動態(tài)和靈活UI設(shè)計。下面通過本文給大家分享Android 使用Fragment模仿微信界面的實(shí)例代碼,需要的的朋友參考下吧
    2017-07-07
  • Android 監(jiān)聽?wèi)?yīng)用前/后臺切換實(shí)例代碼

    Android 監(jiān)聽?wèi)?yīng)用前/后臺切換實(shí)例代碼

    本篇文章主要介紹了Android 監(jiān)聽?wèi)?yīng)用前/后臺切換實(shí)例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-06-06
  • Android實(shí)現(xiàn)自定義dialog的代碼

    Android實(shí)現(xiàn)自定義dialog的代碼

    這篇文章主要介紹了Android實(shí)現(xiàn)自定義dialog的實(shí)例代碼,代碼簡單易懂,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-11-11
  • Android Studio使用ButterKnife和Zelezny的方法

    Android Studio使用ButterKnife和Zelezny的方法

    這篇文章主要為大家詳細(xì)介紹了Android Studio使用ButterKnife和Zelezny的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-04-04

最新評論

颍上县| 衡山县| 金寨县| 伊春市| 昌乐县| 台山市| 益阳市| 和林格尔县| 黄大仙区| 涞源县| 黄平县| 涿州市| 武义县| 天门市| 保山市| 福清市| 井研县| 博罗县| 宁明县| 巩留县| 积石山| 乌鲁木齐市| 郓城县| 万安县| 綦江县| 济南市| 淮安市| 门源| 揭东县| 南阳市| 深州市| 晋中市| 泸西县| 美姑县| 昆山市| 平凉市| 新郑市| 通海县| 呼伦贝尔市| 茂名市| 库尔勒市|