关于linearlayout

LinearLayout----Layout that arranges its children in a single column or a single row.

Linear--线性的,直线的意思

Layout--布局,规划

那么LinearLayout应该就是以线性的方式对它的组件进行布局的吧,只能以横向或纵向的方向规划组件,^_^


 Ex1:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >
    <TextView android:id="@+id/textview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

</LinearLayout>


   Ex2:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
     android:orientation="horizontal"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"  >    
 <GridView android:padding="10dp"   
 android:verticalSpacing="30dp"  
 android:numColumns="auto_fit"  
 android:layout_height="match_parent"   
 android:horizontalSpacing="10dp"  
 android:layout_width="match_parent"   
 android:id="@+id/GridView01"   
 android:gravity="center"  
 android:stretchMode="columnWidth"  
 android:columnWidth="80dp">
 </GridView>  
</LinearLayout>

Ex31: 纵向显示

<?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" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
         android:textSize="50dp"
        android:text="@string/hello"/>
    
    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Hello, I am a TextView" />
    
    <Button android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Hello, I am a Button" />   
</LinearLayout>


Ex32:横向显示

<?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="horizontal" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
         android:textSize="20dp"
         android:rotation="90"
        android:text="@string/hello"/>
    
    <TextView android:id="@+id/text"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
				android:rotation="90"
              android:text="TextView" />
    
    <Button android:id="@+id/button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:rotation="90"
            android:text=" Button" />   
</LinearLayout>


Ex4:

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
    android:orientation="vertical"    
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"  
    >  
    <TextView android:layout_width="fill_parent"    android:textColor="#ffffff"
        android:layout_height="wrap_content"  android:text="Custom Launcher"
     />  
<RelativeLayout  
    android:id="@+id/myView"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"    
    >  
<com.gsl.launcher.ScrollLayout  
  xmlns:android="http://schemas.android.com/apk/res/android"  
  android:id="@+id/ScrollLayoutTest"  
  android:layout_width="fill_parent"  
  android:layout_height="fill_parent"  android:background="#000000" >  
</com.gsl.launcher.ScrollLayout>  
  
<com.gsl.launcher.PageControlView    
                android:id="@+id/pageControl"  
                android:layout_width="fill_parent"    
                android:layout_height="40dp"  
                android:background="#8f00000f"    
                android:layout_alignParentBottom="true"  
                android:gravity="center"/>  
</RelativeLayout>  
</LinearLayout>  


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值