无法使子布局在ScrollView中填充其父级

时间:2017-07-27 12:11:46

标签: android android-layout scrollview

我在RelativeLayout内部有一个父布局ScrollView,其中包含多个子布局和RelativeLayout末尾的子布局(即preview_wrapper),用{{1}填充它} match_parent并包含带有Alpha颜色的背景,其LayoutParamclickable设置为true,以便父布局中的任何视图都不可点击。但它不适合我,我无法看到最后一个孩子填充父布局带到前面。然而,当我删除focusable它的工作完美..但我需要将它带到ScrollView内,因为我在ScrollView外部ScrollView我无法滚动布局。

结构:

preview_wrapper

XML:

<ScrollView>
    <RelativeLayout>
        <LinearLayout>
        </LinearLayout>

        <!-- the layout I want to bring in front of above linear layout and cover its parent -->
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/alpha_white"
            android:clickable="true"
            android:focusable="true"
            android:id="@+id/preview_wrapper"
            ></RelativeLayout>


    </RelativeLayout>

</ScrollView>

1 个答案:

答案 0 :(得分:1)

然后将RelativeLayout变为FrameLayout并重新排列子布局,如下所示

<ScrollView>
    <FrameLayout>

        <!-- the layout I want to bring in front of above linear layout and cover its parent -->

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/alpha_white"
            android:clickable="true"
            android:focusable="true"
            android:id="@+id/preview_wrapper"
            ></RelativeLayout>

        <LinearLayout>
        </LinearLayout>
    </FrameLayout>

</ScrollView>