• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
灬丿妖妖灬
博客园    首页    新随笔    联系   管理    订阅  订阅

Android的线性布局方式

计应111班 陈佳

Android的线性布局有两种,分别是水平线性布局和垂直线性布局,属性中orientation为设置线性布局当其="vertical"时,为 垂直线性布局,当其="horizontal"时,为水平线性布局,不管是水平还是垂直线性布局一行(列)只能放置一个控件。

水平线性布局:

01.<?xml version="1.0" encoding="utf-8"?> 
02.<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
03.    android:layout_width="match_parent" 
04.    android:layout_height="match_parent" 
05.    android:orientation="horizontal" > 
06.     
07.    <EditText  
08.        android:layout_width="100dp" 
09.        android:layout_height="wrap_content" 
10.        /> 
11.     
12.    <Button  
13.        android:layout_width="100dp" 
14.        android:layout_height="wrap_content" 
15.        android:text="Button1"/> 
16. 
17.    <Button  
18.        android:layout_width="100dp" 
19.        android:layout_height="wrap_content" 
20.        android:text="button2"/> 
21. 
22.</LinearLayout>

运行结果:

垂直线性布局:

01.<?xml version="1.0" encoding="utf-8"?> 
02.<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
03.    android:layout_width="match_parent" 
04.    android:layout_height="match_parent" 
05.    android:orientation="vertical" > 
06. 
07.    <EditText  
08.        android:layout_width="100dp" 
09.        android:layout_height="wrap_content" 
10.         
11.        /> 
12.     
13.    <Button  
14.        android:layout_width="100dp" 
15.        android:layout_height="wrap_content" 
16.        android:text="Button1"/> 
17. 
18.    <Button  
19.        android:layout_width="100dp" 
20.        android:layout_height="wrap_content" 
21.        android:text="button2"/> 
22. 
23.</LinearLayout> 

总结:水平和垂直布局就在页面的分布上不同,其他都一样的

posted @ 2013-05-20 17:21  灬丿妖妖灬  阅读(201)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3