[英]Linear Layout not visible / Overlapping
我正在嘗試在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>
我得到的是
我想知道代碼有什么問題。 我是android開發的新手。 非常感謝您的幫助。
在此先感謝Aman Gautam
由於默認設置,它以水平方向顯示
在main.xml的根目錄中
只是把android:orientation =“ vertical”
我極力推薦這個開源項目(https://github.com/johannilsson/android-actionbar),而不是發布自己的代碼,我在自己的項目中使用了它,並且對我來說效果很好。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.