2013-02-16 68 views
3

所以我有一個ScrollView作爲我的佈局中的最高級......在我的ScrollView中我有一個包含其他視圖的RelativeLayout。問題在於RelativeLayout並不能覆蓋整個佈局,因爲它在大約一半的屏幕處切斷。它的寬度是屏幕的整個寬度,但RelativeLayout的高度停止在ImageView底部的位置。這裏是我的佈局代碼:ScrollView不能很好地與RelativeLayout一起玩

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

任何幫助非常感謝!

+0

使用android:fillViewport =「true」作爲scrollview參數。 – vandzi 2013-02-16 07:44:45

回答

7
<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" > 
+0

你應該添加你的文章和原文的不同之處的解釋。並且添加您爲什麼進行這些更改。 – 2013-04-09 00:37:37

相關問題