界面布局

常用的布局种类
  1. 线性布局LinearLayout:线性布局是最常用、也是最简单的布局之一,共分两种:垂直线性布局(所有控件以垂直方向呈一字型排列)、水平线性布局(所有控件以水平方向呈一字型排列)。排列方向在LinearLayout属性中的android:orientation进行设置。
  2. 切换卡布局TabWidget:切换卡布局常用在分类的功能导航中,如本次短信功能中的“发给家长”OR“发给同事”,每个tab页面中可以进行不同的布局设计。TabWidget的布局稍微复杂一些,而且要遵从模板,详见5中的模板xml。
  3. 垂直线性布局xml模板:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/linearLayoutVertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" 
        android:background="@drawable/bg">
        <TextView
            android:id="@+id/TextView01"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="文本栏Top_1" />
        <TextView
            android:id="@+id/TextView02"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="文本栏Top_2" />
        <TextView
            android:id="@+id/TextView03"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="文本栏Top_3" />
    </LinearLayout>

  4. 水平线性布局xml模板:
    <LinearLayout
        android:id="@+id/linearLayoutHorizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" 
        androi:orientation="horizontal" >
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="密码:" />
        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0.93"
            android:inputType="textPassword" />
    </LinearLayout>

  5. 切换卡布局xml模板:
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/linearLayoutCpy"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" 
        android:background="@drawable/bg2" >
    	<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    	    android:id="@android:id/tabhost"
    	    android:layout_width="fill_parent"
    	    android:layout_height="wrap_content" 
    	    android:layout_weight="4" >
    	    <LinearLayout
    	        android:orientation="vertical"
    	        android:layout_width="fill_parent"
    	        android:layout_height="fill_parent">
    	        <TabWidget
    	            android:id="@android:id/tabs"
    	            android:layout_width="fill_parent"
    	            android:layout_height="wrap_content" />
    	        <FrameLayout
    	            android:id="@android:id/tabcontent"
    	            android:layout_width="fill_parent"
    	            android:layout_height="fill_parent">
    			<!-- 第一个tab布局 -->
    	    	        <LinearLayout
    	    		    android:id="@+id/layout_tab1"
    	           	    android:orientation="vertical"
    	        	    android:layout_width="fill_parent"
    	        	    android:layout_height="fill_parent">
    	        	    <CheckBox
    	        		android:id="@+id/checkbox1"
    	        		android:layout_width="fill_parent" 
    	        		android:layout_height="wrap_content" >
    	        	    </CheckBox>
    	        	    <CheckBox
    	        		android:id="@+id/checkbox2"
    	        		android:layout_width="fill_parent" 
    	        		android:layout_height="wrap_content" >
    	        	    </CheckBox>
    	        	</LinearLayout>
    	                <!-- 第一个tab布局结束 -->
    	                <!-- 第二个tab布局 -->
    	                <LinearLayout
    	    	            android:id="@+id/layout_tab2"
    	           	    android:orientation="vertical"
    	        	    android:layout_width="fill_parent"
    	                    android:layout_height="fill_parent">
    	        	    <CheckBox
    	        		android:id="@+id/checkbox4"
    	        		android:layout_width="fill_parent" 
    	        		android:layout_height="wrap_content" >
    	        	    </CheckBox>
    	        	    <CheckBox
    	        		android:id="@+id/checkbox5"
    	        		android:layout_width="fill_parent" 
    	        		android:layout_height="wrap_content" >
    	        	    </CheckBox>
    	        	</LinearLayout>	                
                            <!-- 第二个tab布局结束 -->
    	    	</FrameLayout>
    	    </LinearLayout>
    	</TabHost>
    </LinearLayout>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值