android - ScrollView 上方的线性布局

标签 android scrollview android-linearlayout

我有一个简单的 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/

相关文章:

android - LinearLayout 在 LinearLayout 全宽下方?

android - ScrollView 隐藏底部线性布局

android - 将 motionEvent 从一个 scrollView 传递到另一个

android - 如何将 RecyclerView 与 NestedScrollView 一起使用?

php - 为什么 MySQL 不存储来自 Android 应用程序的数据

android - 如果外部存储不可用怎么办?

android - ScrollView 不显示

android - ScrollView 不会回到布局的开头 - Android

java - 如何将自定义 View 与其他 UI 组件一起使用?

java - 在 Android Eclipse 环境中链接到其他项目的问题