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>