java - 线性布局不可见/重叠

标签 java android xml

我正在尝试在 android 2.2 中实现类似操作栏的东西。 这是我的 main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<include
    android:id="@+id/header"
    layout="@layout/header"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    />
<ScrollView    
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

>
    <LinearLayout 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:background="@drawable/dark_button"
    >

        <Button 
            android:id="@+id/brand_id"
            android:layout_width="fill_parent"
            android:layout_height="80dip"
            android:text="@string/brand_label"
            android:textColor="@color/white"
            android:background="@drawable/dark_button"
        />
        <Button 
            android:id="@+id/car_id"
            android:layout_width="fill_parent"
            android:layout_height="80dip"
            android:text="@string/car_label"
            android:textColor="@color/white"
            android:background="@drawable/dark_button"
            android:visibility="gone"
        />
        <Button 
            android:id="@+id/model_id"
            android:layout_width="fill_parent"
            android:layout_height="80dip"
            android:text="@string/model_label"
            android:textColor="@color/white"
            android:background="@drawable/dark_button"
            android:visibility="gone"
        />
        <Button
            android:id="@+id/location_id"
            android:layout_width="fill_parent"
            android:layout_height="80dip"
            android:text="@string/location_label"
            android:textColor="@color/white"
            android:background="@drawable/dark_button"
            android:visibility="gone"
        />

        <Button 
            android:id="@+id/submit"
            android:layout_width="fill_parent"
            android:layout_height="80dip"
            android:text="@string/submit_label"
            android:textColor="@color/white"       
            android:layout_marginTop="10dip"
            android:background="@drawable/dark_button"
            android:visibility="gone"
        />
        <ProgressBar
            android:id="@+id/mainProgressBar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:visibility="gone"
        />

    </LinearLayout>
</ScrollView>
</LinearLayout>

这是我的 header.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal" 
>

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button"
    android:layout_weight="1" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/logo_toyota"
    android:layout_weight="1" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"        
    android:text="Button"
    android:layout_weight="1" />

</LinearLayout>

我得到的o/p为ScreenShot, Only header is visible

我想知道代码有什么问题。我是安卓开发新手。非常感谢任何帮助。

提前致谢 阿曼·高塔姆

最佳答案

由于默认设置,因此以水平方向显示

ma​​in.xml的根布局中

只需输入android:orientation="vertical"

关于java - 线性布局不可见/重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9703849/

相关文章:

java - JPQL 查询不为空

JavaMelody 在启动 Tomcat 时抛出 NullPointerException

Android:错误:不能从静态上下文引用非静态类型变量 T

android - 将文件保存到内部存储

java - Android我自己的XML资源对象类型

sql - 如何查询包含 XML(不是 xml 列类型)的 SQL Server TEXT 列中的值

java - 在 Closable.close() 中抛出运行时异常

java - 在java中将构造函数链接在一起

java - 使用 android 进行 Ant emma 测试 "Could not find file coverage.em to delete."

c# - 使用 Objective C 从 MS 数据库获取数据?