我想知道在android中有可能有2个嵌套布局吗?我在滚动视图中有表格布局。我想添加另一种布局类型(不确定哪一种),但我尝试崩溃的每个人。
<?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 :(得分:0)
Scrollview文档有时很有趣:
http://developer.android.com/reference/android/widget/ScrollView.html
可以通过滚动的视图层次结构的布局容器 用户,允许它大于物理显示。一个ScrollView 是一个FrameLayout,意味着你应该在其中放置一个孩子 滚动的全部内容;这个孩子本身可能是一个布局 具有复杂的对象层次结构的管理器。经常是孩子 used是一个垂直方向的LinearLayout,呈现一个 用户可以滚动的顶级项目的垂直数组。
正如他们所建议的,你应该放一个包含你的TableLayout
的LinearLayout答案 1 :(得分:0)
尝试使用这样的布局围绕这两个表;
<ScrollView>
<RelativeLayout>
<TableLayout>
</TableLayout>
<TableLayout>
</TableLayout>
<RelativeLayout>
</ScrollView>