2011-08-09 104 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>