线性布局或滚动视图被推离屏幕

问题描述 投票:1回答: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>

我已经尝试使最外面的布局成为相对布局,但滚动视图与嵌套的相对布局重叠。任何人都可以提出建议吗?

android view scrollview android-linearlayout off-screen
1个回答
0
投票

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

将宽度设置为0dp,它将起作用。 :)

© www.soinside.com 2019 - 2024. All rights reserved.