2012-03-14 2 views
0

나는 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> 

내가 코드에 어떤 문제가 있는지 궁금 ScreenShot, Only header is visible

와 O/P를 얻고있다 . 나는 안드로이드 개발에 처음이다. 어떤 도움을 주셔서 감사합니다. 사전에

덕분에 아만 가우 탐이

main.xml에

의 루트 레이아웃에서 기본

으로 설정되어 있기 때문에 그것은 수평 방향으로 보였다되어

+3

문제를 설명하는 것을 잊어 버리셨습니까? – waqaslam

+0

오우 죄송합니다! 내가 정교하게 생각해야만한다고 생각했습니다. 포함 된 부분 만 main.xml에 표시됩니다. 버튼도 표시되어야합니다. 나는 무엇이 잘못되었는지 모른다. –

답변

2

그냥 안드로이드를 넣어 : 방향 = "vertical"

+0

고마워요. 아난드. 그것은 일했다 :) –

2

자신의 코드를 공개하는 대신이 오픈 소스를 적극 권장합니다. 프로젝트, (https://github.com/johannilsson/android-actionbar), 나는 내 자신의 프로젝트에서 그것을 사용했고 그것은 나를 위해 아주 잘 작동했다.

+0

도서관을 추천하는 것이 좋습니다. 대신 ActionBarSherlock을 살펴 보는 것이 좋습니다. http://actionbarsherlock.com/ – elevine

+0

프로젝트를 알고 있지만 시도한 적이 없으며 주장만큼이나 좋은가요? 내가 추천 한 라이브러리는 사용하기 쉽고, 반면 ActionBarSherlock은 ICS에서 제공하는 것과 동일한 API (그러나 다른 패키지 이름)를 사용하므로 _and_는 훨씬 더 나은 기능을 제공합니다. 두 가지 모두 장점이 있다고 생각합니다. 따라서 두 가지를 모두 공부하고 자신의 필요에 가장 적합한 것을 결정해야합니다. – Kai

+2

저는 ActionBarSherlock을 사용했으며 그 주장에 부응합니다. 일반적으로 안드로이드 개발자들로부터 높은 평가를 받고 있습니다. 가장 좋은 기능 중 하나는 바로 ActionBar와의 하위 호환성을 제공하기 때문에 Android 3.0 이상의 기기에서는 ABS가 기본 API를 대신하게됩니다. – elevine

관련 문제