Android 按最大高度等距布置直线

Android 按最大高度等距布置直线,android,android-layout,Android,Android Layout,我在XML文件中定义了一个表行。 它包含3个“线性布局”,一个在另一个之上: 我想看看这个: |-------------------------------| | | | a | | | | | |-------------------------------|

我在XML文件中定义了一个表行。 它包含3个“线性布局”,一个在另一个之上: 我想看看这个:

|-------------------------------|
|                               |
|              a                |
|                               |
|                               |
|-------------------------------|
|                               |
|              b                |
|-------------------------------|
|                               |
|              c                |
|-------------------------------|
“问题”在于,
线性布局
“a”可能会展开并处于不同的高度,而“b”和“c”始终处于相同的高度

我想找出
线性布局
的最大高度,并将此高度强制为所有其他
线性布局
的高度,因此我将为每一行提供以下外观:

|-------------------------------|
|                               |
|              a                |
|                               |
|                               |
|-------------------------------|
|                               |
|              b                |
|                               |
|                               |
|-------------------------------|
|                               |
|              c                |
|                               |
|                               |
|-------------------------------|
我尝试使用android:layout\u weight但没有成功


有什么想法吗?

我试图在一个例子中实现这一点。 以下是我所做的:

<?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="wrap_content"
        android:layout_weight="1"
        android:background="#ff0000"
        >
           <TextView 
            android:layout_width="30dip"
            android:layout_height="wrap_content"
            android:text="hjadsh haksj hasjk haksj hjkas hkjas hjkas hkjas "
            android:textColor="#000000"
            />

    </LinearLayout>

        <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#00ff00"
        ></LinearLayout>

        <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:background="#0000ff"
        ></LinearLayout>

</LinearLayout>

我在第一个布局中使用了textview来显示它可以满足您的需要。 您还可以固定布局b&c的高度,使其具有固定高度,并通过设置布局高度:包裹内容来改变布局a

您现在可以根据需要定制它。

试试这个

<?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="wrap_content"
    android:layout_weight="1"  >  
    </LinearLayout>

    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="#00ffff"
    ></LinearLayout>

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

>

layout\u weight是正确的方法,您是如何尝试使用它的?要使
android:layout\u weight
正常工作,您必须将每个
LinearLayout
android:layou height
设置为
0dp
。我已经尝试了
android:layou height
(0dp,wrap\u content,…)没有成功-我总是得到同样不想要的眼神。与此同时,我给了顶级父级固定的
dp
大小,现在它显然起作用了,但这不是最好的方法。。。