Линейный макет или скроллвью отталкиваются от экрана

По какой-то причине скроллвью отталкивается от экрана

<?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>

я попытался сделать внешний макет относительным макетом, но затем представление прокрутки перекрывается с вложенным относительным макетом. Кто-нибудь может предложить предложение?

1 ответ

Это не работает, потому что вы используете match_parent в качестве высоты, поэтому RelativeLayout занять все пространство. Вес используется, чтобы распределить оставшееся пустое пространство или убрать пространство, когда общая сумма больше, чем LinearLayout.

Вместо этого установите ширину 0dp, и она будет работать.:)

Другие вопросы по тегам