gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 19:06:52 26 4
gpt4 key购买 nike

我正在尝试在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com