2013-06-06 76 views
0

你好我的應用程序相對佈局背景不能充分伸展它screen.And正在顯示像下面enter image description here我相對佈局背景不拉伸全屏

我的XML文件::

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


<RelativeLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#CACACA" 
android:orientation="vertical" > 
+1

那是因爲滾動視圖。滾動查看孩子無法填充高度。 –

+0

那我可否知道這個選擇? – KCRaju

+0

您可以採用scrollview的高度和rel的高度。佈局。如果scrollview.height()> relativelayout.height()然後relativelayout.height()= scrollview.height(); –

回答

-1

這種嘗試:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#CACACA"> 


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

...... 
+0

是的,但RelativeLayout的高度應該設置爲wrap_content –

+0

@DoctororDrive是的,但它不會在屏幕輸出上產生任何影響。 –

+1

@PratikSharma我降低了投票率,因爲這並沒有按照KCRaju的要求將視圖拉伸到全屏,layout_height也應該是wrap_content,並且方向不應該在那裏。 user2458464提供的答案就是它。 –

9

提供android:fillViewPort = true爲scrollView。

+2

這應該是正確的答案,以供參考:http://wwwcurious-creature.org/2010/08/15/scrollviews-handy-trick/ –

2

試試這個:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#CACACA" 
    android:fillViewPort="true" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" > 
    </RelativeLayout> 

</ScrollView>