Android 为什么';我的相对布局不占整个屏幕高度吗

Android 为什么';我的相对布局不占整个屏幕高度吗,android,scrollview,android-relativelayout,Android,Scrollview,Android Relativelayout,所以,我有一些文本和按钮的简单布局。文本定位在起始位置,在某些手机上,它的高度比屏幕的高度高,因此我将其定位在滚动视图中。在该文本旁边,我还有一个文本视图和一个按钮,该按钮应位于屏幕的右下角。问题是,在一个大屏幕上,我的按钮不在底部,而是在文本结束的地方,我可以看到我的relativelayout并没有占据scrollView的整个高度。我的布局: <ScrollView xmlns:android="http://schemas.android.com/apk/res/a

所以,我有一些文本和按钮的简单布局。文本定位在起始位置,在某些手机上,它的高度比屏幕的高度高,因此我将其定位在滚动视图中。在该文本旁边,我还有一个文本视图和一个按钮,该按钮应位于屏幕的右下角。问题是,在一个大屏幕上,我的按钮不在底部,而是在文本结束的地方,我可以看到我的relativelayout并没有占据scrollView的整个高度。我的布局:

<ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:text="Some dummy text"
        android:textColor="#969696"
        android:textSize="13dp" />




    <TextView
        android:id="@+id/text2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="false"
        android:layout_below="@+id/text1"
        android:text="some dummy text2"
        android:textColor="#969696"
        android:textSize="13dp" />



    <ImageButton
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/btn49_2x" />

</RelativeLayout>

</ScrollView>

我的实际布局有点复杂,所以我需要使用相对布局。但是如何确保它占据整个屏幕的高度呢


我尝试将高度设置为“包裹:内容”,但没有效果。

android:fillViewport=“true”
添加到您的滚动视图中

为什么不直接设置layout\u height=“fill\u parent”?选中@idaNakav answer将解决您的问题。由于滚动视图的原因,请删除滚动视图或添加android:fillViewport=“true”在里面ScrollView@ManmeetSinghBatra你知道他为什么使用ScrollView>吗?有人能解释一下为什么投反对票吗?这是一个真正的问题,我没有看到任何副本,我得到了真正的答案。