2011-08-09 79 views
0

我想知道是否有可能在android中有2個嵌套的佈局?我在滾動視圖中有表格佈局。我想添加另一個佈局類型(不知道哪一個),但我嘗試崩潰的每個人。嵌套在滾動視圖中的佈局(其中一個表格佈局) - Android?

<?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"> 
    <TableLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      xmlns:android="http://schemas.android.com/apk/res/android"> 
    </TableLayout> 
    <TableLayout 
       android:id="@+id/tblLayout" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       xmlns:android="http://schemas.android.com/apk/res/android"> 

      .... rows here .... 
    </TableLayout> 

</ScrollView> 

這會崩潰的SetContentView(Resource.Layout.MyLayout);

「這下要執行的語句時,從 當前函數這個線程的回報。」

如果我只在ScrollView中有一個佈局,它將加載。

回答

0

滾動型文檔有時有趣:

http://developer.android.com/reference/android/widget/ScrollView.html

爲能夠由用戶 滾動,允許它比物理顯示器大視圖層次佈局容器。 A ScrollView 是一個FrameLayout,這意味着你應該在其中放置一個小孩包含 的全部內容進行滾動;這個孩子本身可能是一個佈局複雜的對象層次結構的經理。一個經常使用 的孩子是一個垂直方向的LinearLayout,它呈現一個頂級項目的垂直數組,用戶可以滾動瀏覽。

當他們建議,你應該把一個LinearLayout中同時包含您的TableLayout的

0

嘗試,圍繞着這樣一個佈局的兩個表;

<ScrollView> 
    <RelativeLayout> 
     <TableLayout> 
     </TableLayout> 
     <TableLayout> 
     </TableLayout> 
    <RelativeLayout> 
</ScrollView>