1

出于某种原因,滚动视图被推离屏幕

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_new_male_female_sf"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:orientation="horizontal" >

<RelativeLayout
    android:orientation="vertical"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_weight="2" >

    <RelativeLayout
        android:id="@+id/rel_layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

     //DYNAMICALLY PUTTING IMAGEVIEW HERE   

    </RelativeLayout>

    <Button
        android:id="@+id/next_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

</RelativeLayout>

<ScrollView
    android:id="@+id/scrollview"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_weight="3" >

    <LinearLayout
        android:id="@+id/selection_bar"
        android:orientation="vertical"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

    </LinearLayout>

</ScrollView>

</LinearLayout>

我尝试将最外面的布局设为相对布局,但随后滚动视图与嵌套的相对布局重叠。任何人都可以提供建议吗?

4

1 回答 1

0

它不起作用,因为您使用 match_parent 作为高度,因此RelativeLayout占用了所有空间。当总和大于 LinearLayout 时,权重用于分配剩余的空白空间或带走空间。

将宽度设置为 0dp 即可。:)

于 2014-07-16T18:22:03.463 回答