2011-08-03 25 views
0

我想做一個嵌套的relativeLayout視圖的滾動視圖。相關的佈局有一個背景圖像。當realativeLayout是唯一的佈局背景圖像是我想要它的大小。ScrollView爲什麼讓我的背景圖片更大?

當我添加滾動視圖,它使圖像變大,我不知道爲什麼和我需要設置什麼屬性來解決它。

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 
    <RelativeLayout android:id="@+id/mainLayout" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/background2" 
      xmlns:android="http://schemas.android.com/apk/res/android"> 
     <TextView android:id="@+id/txtApplicationTitle" 
        android:text="My Application" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:layout_marginTop="5dp" 
        android:textSize="15dp" 
        android:layout_alignParentTop="true" 
        android:layout_alignLeft="@+id/txtAbout" /> 
     <TextView android:id="@+id/txtPrivacyHeader" 
        android:layout_width="wrap_content" 
        android:text="@string/PrivacyHeader" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:layout_height="wrap_content" 
        android:layout_alignParentTop="true" 
        android:layout_alignParentLeft="true" 
        android:layout_marginLeft="21dp" 
        android:layout_marginTop="94dp" /> 
     <TextView android:id="@+id/Privacy" 
        android:layout_width="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceMedium" 
        android:text="@string/Privacy" 
        android:layout_height="wrap_content" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentRight="true" 
        android:layout_below="@+id/txtPrivacyHeader" 
        /> 
    </RelativeLayout> 
</ScrollView> 

//這是我得到什麼(你不能告訴,但它是可滾動)

http://gyazo.com/eab982b9d1832983d72197488438cb48.png

//這個我想怎麼SrcollView看(這是完全一樣的代碼如上只是沒有滾動型包裹吧)

http://gyazo.com/b57ff76d74b57f7fdc047df57e7d2d41.png

見頂部如何擁有所有的突然增長這麼多。

+0

在哪些方面讓你的形象變得更大...? (寬度,高度,適合等等)。你有沒有嘗試將scrollview layout_width設置爲wrap_content? –

+0

@ Adam Storm - 身高越來越大。當我將滾動視圖包裹在相應的佈局中時,我說至少增加了10-15%。我嘗試了wrap_content,它似乎什麼也沒做。 – chobo2

+0

@ Adam Storm - 我測量的和我想要的高度(這是沒有滾動條佈局包裝相對佈局)是71pxs。當我把滾動視圖圍繞它,它去87pxs – chobo2

回答

0

您的ScrollView已將其高度設置爲wrap_content,並且您的RelativeLayout將其高度設置爲fill_parent。這意味着您的ScrollView將擴展到整個視圖。

+0

是否應該不擴展整個視圖?你認爲他們應該是什麼,所以我可以試試看。背景圖像應占據整個視圖。它的頂部不應該如此拉伸。 – chobo2

+0

我更改了代碼來表示不同的視圖,我正在處理同樣的問題,但更加明顯。我還添加了一些截圖。 – chobo2