Android 线性布局';它紧挨着彼此

Android 线性布局';它紧挨着彼此,android,Android,我试图有两个线性布局的旁边彼此,但下面的代码无法工作,它把他们这样一个是在顶部 你能帮忙吗。还是你有更好的主意 谢谢 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <L

我试图有两个线性布局的旁边彼此,但下面的代码无法工作,它把他们这样一个是在顶部

你能帮忙吗。还是你有更好的主意

谢谢

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

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" 
    android:layout_weight="0.5"
    android:background="#999"> 



</LinearLayout>

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" 
android:layout_weight="0.5"
    android:background="#977000"> 



</LinearLayout>



</LinearLayout>

尝试将第一个线性布局设置为“水平”,而不是“垂直”

尝试将第一个线性布局设置为“水平”,而不是“垂直”

<

android:orientation="vertical" >
一定是

android:orientation="horizontal" >
在您的外线布局中

android:orientation="vertical" >
android:orientation="horizontal"
一定是

android:orientation="horizontal" >

在您的外部线性布局中

android:orientation=“vertical”
替换顶部
LinearLayout中的
android:orientation=“horizontal”

android:orientation=“horizontal”
替换顶部
线性布局中的
android:orientation=“vertical”
android:orientation="horizontal"
<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="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal" 
android:layout_weight="1"
android:background="#999"> 
</LinearLayout>
<LinearLayout 
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal" 
android:layout_weight="1"
android:background="#977000"> 
</LinearLayout>
</LinearLayout>

使用此项仅需更改
android:orientation=“horizontal”
即可代替
android:orientation=“vertical

  <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="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="0.5"
    android:background="#999"
    android:orientation="horizontal" >
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="0.5"
    android:background="#977000"
    android:orientation="horizontal" >
</LinearLayout>


使用此项仅需更改
android:orientation=“horizontal”
即可代替
android:orientation=“vertical

  <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="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="0.5"
    android:background="#999"
    android:orientation="horizontal" >
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_weight="0.5"
    android:background="#977000"
    android:orientation="horizontal" >
</LinearLayout>


将外部线性布局的方向设置为“水平”。。它工作

将外部线性布局的方向设置为“水平”。。它起作用了