【发布时间】:2011-12-16 19:35:25
【问题描述】:
我有一个简单的 android 布局,其中包含一个包含 tablelayout 的滚动视图。该表正确显示,但我想在滚动视图上方添加一个静态标题,以便基本上表中列的标签始终保持在屏幕顶部。但是,当我在布局文件中的<ScrollView> 上方添加<LinearLayout> 时,它会全部消失。
谁能发现我的 xml 文件做错了什么?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="top" >
<LinearLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableLayout
android:id="@+id/mainTable"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</ScrollView>
</LinearLayout>
事实上,我看不到滚动视图或表格布局,但如果我删除 header 线性布局,它会显示得很好。
【问题讨论】:
-
你为什么不设置任何LinearLayouts 的方向?
-
因为这正是我需要做的......让它成为一个答案,这样我就可以接受它
标签: android scrollview android-linearlayout