Android 儿童';带有match_父蚂蚁最小高度问题的RelativeLayout的布局

Android 儿童';带有match_父蚂蚁最小高度问题的RelativeLayout的布局,android,android-layout,Android,Android Layout,我有个奇怪的问题。我有LinearLayout,它包含一些固定大小的元素和一个RelativeLayout,它使用父空间的剩余空间(权重=1)。简单布局: <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" and

我有个奇怪的问题。我有LinearLayout,它包含一些固定大小的元素和一个RelativeLayout,它使用父空间的剩余空间(权重=1)。简单布局:

<ScrollView 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:fillViewport="true" >

    <LinearLayout
        android:id="@+id/LinearLayout1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        tools:context=".LoginActivity" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="16dp"
            android:layout_marginTop="@dimen/space_between_views"
            android:src="@drawable/logo" />

        <EditText
            android:id="@+id/login"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="8dp"
            android:ems="10"
            android:hint="@string/login"
            android:inputType="text"
            android:singleLine="true"
            android:text="aneworld@gmail.com" >

            <requestFocus />
        </EditText>

        <EditText
            android:id="@+id/password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ems="10"
            android:hint="@string/password"
            android:inputType="textPassword"
            android:singleLine="true"
            android:text="pandora9" />

        <Button
            android:id="@+id/submit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="8dp"
            android:text="@string/login_button" />

        <RelativeLayout
            android:id="@+id/RelativeLayout1"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:minHeight="100dp" >

            <TextView
                android:id="@+id/support"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_gravity="bottom"
                android:layout_marginTop="0dp"
                android:layout_weight="1"
                android:gravity="center_horizontal|bottom"
                android:padding="8dp"
                android:text="@string/support_number" />

            <TextView
                android:id="@+id/forgot_password"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/support"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="20dp"
                android:padding="@dimen/space_between_views"
                android:text="@string/forgot_password" />

        </RelativeLayout>
    </LinearLayout>

</ScrollView>

我添加了minHeight参数,用于解决小屏幕的问题。但,若父级的剩余空间小于此最小高度,忘记密码子级将转到父级的顶部,则忽略上面的标志。为什么?

我知道另一种方法可以让它起作用,但我只想知道为什么会发生这种情况

我添加了以下内容的屏幕截图:

剩余空间较大,因此忘记密码高于支持:

剩余空间较小,因此忘记密码位于父项的顶部:
不知道此布局有什么问题,但请尝试将所有其他视图包含在父布局中,并为该布局指定权重。这应该可以解决问题。

如果您为RelativeLayout赋予了权重,那么请更改android_布局_height=“0dp”而不是匹配parent@ShaniGoriwal,谢谢,我修好了。但这并不能解决这个相对论的问题。你说的是父母的相对论的孩子吗?你能告诉我应该分配多少重量吗?我的意思是,相对线上方的所有视图都应该包含在线性布局中。指定此线性布局权重(例如1)。然后,您可以根据希望此布局的高度编辑此权重。同样的问题仍然存在。我认为这是一个相对的问题。更改某些内部参数。我知道很多解决这个问题的方法,我只是想知道为什么会发生这种情况。哦,我刚刚意识到你使用的是滚动视图。有什么特别的原因吗?如果您删除ScrollView并以上面提到的方式尝试,它应该可以工作,然后我删除ScrollView,RelativeLayout仅使用剩余空间,minHeight将被忽略。但我必须使用scrollview,否则我不能保证每个用户都能看到所有内容,即使是使用小型手机。