2012-03-14 12 views
0

私はアンドロイド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> 

であり、これは私が、私はコードと間違っているものを疑問に思ってScreenShot, Only header is visible

としてのO/Pを取得しています私の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> 

です。私はアンドロイド開発に新しいです。どんな助けも高く評価されます。 =オリエンテーション:それはmain.xml

のルートレイアウトでは、デフォルト

によって設定されているので、それを水平方向に示したされ、事前 アマンゴータム

+3

問題を説明するのを忘れましたか? – waqaslam

+0

ああ申し訳ありません!私は精巧にしなければならないと思った。含まれている部分だけがmain.xmlに見える。ボタンも表示されるはずです。私は何が間違っているのか分からない。 –

答えて

2

おかげでちょうどアンドロイドを置きます"vertical"

+0

ありがとうAnand。それは働いた:) –

2

独自のコードを展開する代わりに、このオープンソースを強くお勧めしますプロジェクト、(https://github.com/johannilsson/android-actionbar)、私は自分のプロジェクトでそれを使用して、それは私のために非常にうまくいっています。

+0

ライブラリをお勧め良いアイデア。私は代わりにActionBarSherlockを見てみることをお勧めします:http://actionbarsherlock.com/ – elevine

+0

私はプロジェクトを知っていますが、それを試したことはありません、それはそれが主張するように良いですか?私が推薦したライブラリは使いやすいですが、ActionBarSherlockはICSで提供されているのと同じAPI(しかし異なるパッケージ名)を使用しています。だから私はどちらも自分のメリットがあると思うので、両方を勉強し、どちらがあなたのニーズに最も適しているかを決めるべきです。 – Kai

+2

私はActionBarSherlockを使用しました。一般的にAndroid開発者によって高く評価されています。最も優れた機能の1つは、ActionBarとの下位互換性を提供するだけなので、Android 3.0以上のデバイスでは、ABSがネイティブAPIを引き継ぐことになります。 – elevine

関連する問題