Java 线性布局不可见/重叠
我正在尝试在Android2.2中实现类似于动作条的东西。 这是我的main.xmlJava 线性布局不可见/重叠,java,android,xml,Java,Android,Xml,我正在尝试在Android2.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" > <inclu
<?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为
我想知道代码出了什么问题。我是android开发新手。非常感谢您的帮助
提前谢谢
Aman Gautam它以水平方向显示,因为它是默认设置的 在main.xml的根布局中
只需将android:orientation=“vertical”置于水平方向,因为它是默认设置的 在main.xml的根布局中
只需将android:orientation=“vertical”放到自己的代码中,我强烈推荐这个开源项目(https://github.com/johannilsson/android-actionbar),我在自己的项目中使用过它,对我来说效果很好 我强烈推荐这个开源项目,而不是推出自己的代码(https://github.com/johannilsson/android-actionbar),我在自己的项目中使用过它,对我来说效果很好 你忘了解释你的问题了吗?哦,对不起!我想我一定已经详细说明了。只有包含的部分在main.xml中可见。还有一个按钮也应该是可见的。我不知道怎么了。你忘了解释你的问题了吗?哦,对不起!我想我一定已经详细说明了。只有包含的部分在main.xml中可见。还有一个按钮也应该是可见的。我不知道怎么了。推荐一个图书馆是个好主意。不过,我还是建议你看看ActionBarSherlock:我知道这个项目,但从未尝试过,它是否像它宣称的那样好?我推荐的库非常易于使用,另一方面,ActionBarSherlock使用与ICS提供的API相同的API(但包名不同),并且提供了更好的功能。所以我认为两者都有各自的优点,所以你一定要研究它们,决定哪一个最适合你的需要。我用过ActionBarSherlock,它符合它的要求。它通常受到Android开发者的高度评价。最好的功能之一是它只提供了与ActionBar的向后兼容性,因此在Android 3.0和更高版本的设备上,ABS将让本机API接管。推荐一个库是个好主意。不过,我还是建议你看看ActionBarSherlock:我知道这个项目,但从未尝试过,它是否像它宣称的那样好?我推荐的库非常易于使用,另一方面,ActionBarSherlock使用与ICS提供的API相同的API(但包名不同),并且提供了更好的功能。所以我认为两者都有各自的优点,所以你一定要研究它们,决定哪一个最适合你的需要。我用过ActionBarSherlock,它符合它的要求。它通常受到Android开发者的高度评价。最好的特性之一是它只提供了与ActionBar的向后兼容性,因此在Android 3.0和更高版本的设备上,ABS将让本机API接管。