how to design view layout in vertical on android
hi all i need to design开发者_如何转开发 view layout between two linear layout. i see view's property for orientation. i want to put view layout by vertically between linear layout2 and linear layout3. please assist me.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:id="@+id/linearLayout1" android:layout_height="wrap_content">
<LinearLayout android:layout_width="wrap_content"
android:id="@+id/linearLayout2" android:layout_height="wrap_content">
<TextView android:text="TextView" android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:id="@+id/linearLayout3" android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:text="TextView" android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView android:text="TextView" android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>
</LinearLayout>
In Your layout XML file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:id="@+id/linearLayout1" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:layout_width="wrap_content"
android:id="@+id/linearLayout2" android:layout_height="wrap_content">
<TextView android:text="TextView" android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:id="@+id/linearLayoutNEW" android:layout_height="wrap_content">
<TextView android:text="TextView" android:id="@+id/textViewNEW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:id="@+id/linearLayout3" android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:text="TextView" android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView android:text="TextView" android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>
Now You have three LinearLayout with horizontal orientation one under another... Is this what you wanted to achieve?
And it is even not recommended to use LinearLayout when only one control is within it... So next example should be better:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:id="@+id/linearLayout1" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:text="TextView" android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<LinearLayout android:layout_width="wrap_content" android:orientation="vertical"
android:id="@+id/linearLayoutNEW" android:layout_height="wrap_content">
<TextView android:text="TextView" android:id="@+id/textViewNEW1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<TextView android:text="TextView" android:id="@+id/textViewNEW2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:id="@+id/linearLayout3" android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:text="TextView" android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<TextView android:text="TextView" android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
</LinearLayout>
精彩评论