1

现在它垂直分裂......我希望它水平分裂。我看过其他所有说他们的水平切割的人,我无法区分...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="top"
    android:layout_weight="1" >
</LinearLayout>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    android:layout_weight="1" >
</LinearLayout>

</LinearLayout>
4

3 回答 3

6

将您的方向更改为vertical

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

 <LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="top"
android:layout_weight=".1" >
 </LinearLayout>

 <LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:layout_weight=".1" >
</LinearLayout>

 </LinearLayout>
于 2012-10-17T12:55:52.823 回答
1

你应该让子视图`fill_parent

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:weightSum="2" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1" >
    </LinearLayout>

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1" >
    </LinearLayout>

</LinearLayout>

LinearLayout这将并排创建 2 L 个对象。

如果你想在另一个之上创建一个,你应该android:orientation="vertical"改为

于 2012-10-17T13:02:35.263 回答
0

这应该有效。

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

<LinearLayout
    android:layout_width="0dip"
    android:layout_height="match_parent"
    android:layout_gravity="top"
    android:layout_weight="1" >
</LinearLayout>

<LinearLayout
    android:layout_width="0dip"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    android:layout_weight="1" >
</LinearLayout>

</LinearLayout>
于 2012-10-17T12:56:14.593 回答