激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務器之家:專注于服務器技術及軟件下載分享
分類導航

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

服務器之家 - 編程語言 - Java教程 - Android中的LinearLayout布局

Android中的LinearLayout布局

2020-07-24 12:16bigboss位 Java教程

在一般情況下,當有很多控件需要在一個界面列出來時,我們就可以使用線性布局(LinearLayout)了,線性布局是按照垂直方向(vertical)或水平方向(horizontal)的順序依次排序子元素,每一個子元素都位于前一個元素之后,下面我們就簡單的了解一

LinearLayout : 線性布局

在一般情況下,當有很多控件需要在一個界面列出來時,我們就可以使用線性布局(LinearLayout)了,  線性布局是按照垂直方向(vertical)或水平方向(horizontal)的順序依次排序子元素,每一個子元素都位于前一個元素之后,下面我們就簡單的了解一下吧

在XML布局文件中會遇到如下一些單位

px:是屏幕的像素點   dp:一個基于density的抽象單位,屏幕的物理尺寸   sp:同dp相似,但會根據用戶的字體大小進行縮放 

XML代碼如下:改變一下android:orientation="vertical"  垂直方向(vertical)

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical"
 tools:context="com.example.administrator.adapter.MainActivity">
 <TextView
  android:text="第一個TextView"
  android:background="#ef0808"
  android:gravity="center"
  android:textSize="18sp"
  android:layout_width="match_parent"
  android:layout_height="100dp" />
 <TextView
  android:text="第二個TextView"
  android:gravity="center"
  android:background="#31ef0b"
  android:textSize="18sp"
  android:layout_width="match_parent"
  android:layout_height="100dp" />
 <TextView
  android:text="第三個TextView"
  android:gravity="center"
  android:textSize="18sp"
  android:background="#ec07ca"
  android:layout_width="match_parent"
  android:layout_height="100dp" />
 <TextView
  android:text="第四個TextView"
  android:gravity="center"
  android:textSize="18sp"
  android:background="#f5d105"
  android:layout_width="match_parent"
  android:layout_height="100dp" />
</LinearLayout>

運行結果:每一個TextView都從上往下依次排列

Android中的LinearLayout布局

XML代碼如下:改變一下android:orientation="horizontal"  水平方向(horizontal)

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="horizontal"
 tools:context="com.example.administrator.adapter.MainActivity">
 <TextView
  android:text="第一個TextView"
  android:background="#ef0808"
  android:gravity="center"
  android:textSize="18sp"
  android:layout_width="100dp"
  android:layout_height="100dp" />
 <TextView
  android:text="第二個TextView"
  android:gravity="center"
  android:background="#31ef0b"
  android:textSize="18sp"
  android:layout_width="100dp"
  android:layout_height="100dp" />
 <TextView
  android:text="第三個TextView"
  android:gravity="center"
  android:textSize="18sp"
  android:background="#ec07ca"
  android:layout_width="100dp"
  android:layout_height="100dp" />
 <TextView
  android:text="第四個TextView"
  android:gravity="center"
  android:textSize="18sp"
  android:background="#f5d105"
  android:layout_width="100dp"
  android:layout_height="100dp" />
</LinearLayout>

運行結果:每一個TextView都從左向右依次水平排列

Android中的LinearLayout布局

這兩種線性布局唯一的差別就是android:orientation的值不同

實驗總結:這兩種線性布局唯一的差別就是android:orientation的值不同, 通過本次實驗對Android中的線性布局有了一個初步的了解

 以上就是本文的全部內容,希望本文的內容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持服務器之家!

原文鏈接:http://www.cnblogs.com/bigbossOne/p/6259937.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 免费观看一级淫片 | 一级免费观看 | 蜜桃视频网站在线观看 | 一级影片在线观看 | 亚洲综合一区二区三区 | 中文字幕偷拍 | 国产精品一区二区三区99 | 色网在线视频 | 日日操夜夜透 | 涩涩伊人 | 一级大黄毛片免费观看 | 色诱亚洲精品久久久久久 | 成人午夜看片 | 欧美亚洲黄色 | 女人一级一级毛片 | 美女av在线免费观看 | 久久久噜噜噜久久熟有声小说 | 成人在线视频免费看 | 精品国产96亚洲一区二区三区 | av电影在线免费观看 | 亚洲免费网站 | 久久久久久久久久综合 | 色婷婷一区二区三区 | 久久精品日产高清版的功能介绍 | 黄在线看| 毛片在线免费播放 | 久草在线视频网 | 亚洲欧美日韩在线 | 久久国产亚洲精品 | 成年免费网站 | 亚洲影院在线观看 | 精品一区二区三区免费毛片 | 麻豆蜜桃在线观看 | 91成人久久| 国产成人在线综合 | 久久伊人国产精品 | 九九色在线观看 | 成人一区二区在线观看视频 | 毛片大全 | 欧美视频一二区 | 欧美成人精品欧美一级乱黄 |