我有一个简单的 Android 布局,由包含表格布局的 ScrollView 组成。该表显示正确,但我想在 ScrollView 上方添加一个静态标题,以便基本上表中列的标签始终保留在屏幕顶部。但是,当我添加 <LinearLayout>
上面<ScrollView>
在我的布局文件中,它使它全部消失。
任何人都可以发现我的 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>
事实上,我看不到 ScrollView 或表格布局,但如果我删除 header
线性布局,它显示得很好。
最佳答案
LinearLayouts需要设置 android:orientation
参数。
关于android - ScrollView 上方的线性布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8539246/