2013-04-07 60 views
2

爲什麼滾動視圖內的線性佈局不適合屏幕尺寸? 我試圖用「Layout_Height」做一些改變,但沒有成功。線性佈局不適合屏幕尺寸

這是我的XML代碼:

感謝您的幫助!

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@drawable/background" 
     android:orientation="vertical" > 
     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      style="@style/HeaderText" 
      android:orientation="vertical" > 
    <!-- ++++++++++++++++++ Row18 ++++++++++++++++++ --> 
      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" >     
       <Button 
        android:id="@+id/btnBack" 
        android:text="@string/Back" 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1.00" 
        android:textSize="15dip" /> 
       <Button 
        android:id="@+id/btnSave" 
        android:text="Save" 
        android:layout_width="0dp" 
        android:layout_height="match_parent" 
        android:layout_weight="1.00" 
        android:textSize="15dip" /> 
      </LinearLayout> 

    <!-- +++++++++++++++++++++++++++++++++++++++++++ --> 
     </LinearLayout> 
    </LinearLayout> 
</ScrollView> 

回答

0

1)爲什麼你會嵌套LinearLayout一個LinearLayout內的另一個LinearLayout裏面?我只能假設這只是你的XML文件的摘錄,否則這沒有任何意義。

2)究竟什麼是你遇到了問題? LinearLayout太長,所以它會離開底部的可見屏幕? 如果是這樣,這是由於ScrollView作爲父元素。 A ScrollView將通過設置android:layout_height="match_parent"填滿屏幕。一個ScrollView本身給予高度與其子女的無限空間,所以設置android:layout_height="match_parent"子視圖(LinearLayout)將使其承擔無限空間以及內。你應該把它設置爲android:layout_height="wrap_content",看看這是否適合你!

+0

沒有,線性佈局太短,所以當我運行在一個符大小的線性佈局切斷在屏幕中間的程序。 – user2235615 2013-04-07 11:40:54

+0

垂直切割中間或水平?你可以發佈一個截圖嗎? – chuky 2013-04-07 11:46:15

+0

抱歉,我是新來的,我不知道如何加載圖像。 水平地在屏幕中間。 – user2235615 2013-04-07 11:54:00

5

我無法發表評論,所以我會盡力回答: 您是否嘗試在ScrollView中設置android:fillViewport="true"