2012-03-31 43 views
2

我試圖在多個TextView和一些按鈕組成的Android中實現佈局。我想要其中一個TextView(它是我正在實現的遊戲的日誌)佔用它擁有的所有可用空間,如果顯示的文本太多,可以滾動。不過,我似乎無法得到它的下方沒有覆蓋的觀點,當它膨脹 - 相反,它停在屏幕的底部:使TextView展開而不覆蓋其他視圖

enter image description here

在這個截圖中,有一個「記分牌」的TextView ,「手」TextView,「日誌」TextView和帶有幾個按鈕的LinearLayout。所有TextView s都有動態長度,但前兩個不應占用超過幾行。麻煩的是,日誌擴展並覆蓋它下面的按鈕(在正面,它是可滾動的)。你能告訴我如何解決這個問題嗎?

這裏的佈局XML:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" > 

    <TextView 
     android:id="@+id/scoreboard" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:text="Scoreboard" /> 

    <TextView 
     android:id="@+id/handinfo" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/scoreboard" 
     android:text="Hand" /> 

    <LinearLayout 
     android:id="@+id/linearLayout1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" > 

     <Button 
      android:id="@+id/stay" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:enabled="false" 
      android:text="Stay" /> 

     <Button 
      android:id="@+id/leave" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:enabled="false" 
      android:text="Leave" /> 

     <Button 
      android:id="@+id/pay" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:enabled="false" 
      android:text="Pay" /> 

     <Button 
      android:id="@+id/payWithWild" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:enabled="false" 
      android:text="Pay Wild" /> 

     <Button 
      android:id="@+id/dontPay" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:enabled="false" 
      android:text="Don&apos;t Pay" /> 
    </LinearLayout> 

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/handinfo" > 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/log" 
      android:text="" /> 

    </ScrollView> 



</RelativeLayout> 

回答

4

添加以下屬性到您ScrollView,它應該可以解決顯示:

android:layout_below="@id/handinfo" 
android:layout_above="@id/linearLayout1" 
+0

那麼簡單。它的工作原理,謝謝! – 2012-03-31 10:34:49