ScrollView和RelativeLayout不相容

3

所以我有一个ScrollView作为我的布局中的最高级别...在我的ScrollView内部,我有一个RelativeLayout,其中包含其他视图。问题是RelativeLayout没有像应该那样覆盖整个布局,它在大约半个屏幕处被截断。它的宽度是屏幕的全部宽度,但RelativeLayout的高度停在ImageView底部。这是我的布局代码:

<?xml version="1.0" encoding="utf-8"?>    
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" 
android:background="@drawable/graybck">

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

<ImageView
    android:id="@+id/pPicture"
    android:layout_width="200dip"
    android:layout_height="300dip"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" />

<TextView
    android:id="@+id/pName"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginTop="29dp"
    android:layout_toRightOf="@+id/pPicture"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/pBio"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/pName"
    android:layout_below="@+id/pName"
    android:layout_marginTop="22dp"
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
    android:id="@+id/stats"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignTop="@+id/pName"
    android:layout_marginRight="266dp"
    android:text="Loading Stats..." />

</RelativeLayout>

</ScrollView>

非常感谢您的帮助!


使用android:fillViewport="true"作为ScrollView参数。 - Martin Vandzura
2个回答

6
<Scrollview> 
    <LinearLayout>
        <RelativeLayout>
        inner part here ...
        </RelativeLayout>
    </LinearLayout>  
</Scrollview>

试着使用这样的东西。


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

你应该添加解释你的帖子和原帖之间的区别,并说明为什么进行了这些更改。 - Hugo Dozois

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接