2013-08-01 90 views
1

我構建了一個帶有片段的應用程序,並在頂部有一個帶有搜索小部件的ListView。這個ListView佈局是一個片段的佈局。每當我啓動應用程序時,SearchWidget頂部都會出現一個惱人的白色部分,這會讓整個佈局看起來很奇怪,而我似乎無法擺脫它。它低於標題。但是也許我做錯了什麼,也許這跟操作欄有關?我是新來的碎片,並從未使用過操作欄。也許我也使用它錯了。有沒有可能擺脫它,或者我應該做一些不同的事情? http://imgur.com/rzcLztY(佈局的形象 - 白色的空間,我想擺脫什麼)Android片段:頂部空的空間

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:baselineAligned="false" 
android:orientation="horizontal" > 

<fragment 
    android:id="@+id/listFragment" 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_marginTop="?android:attr/actionBarSize" 
    android:layout_weight="1.12" 
    class="org.blabla.ListFragment" 
    tools:layout="@layout/activity_people_list" > 
</fragment> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
tools:context=".PeopleListActivity" > 

<SearchView 
    android:id="@+id/searchView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:gravity="center_vertical" /> 

<ListView 
    android:id="@+id/listView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    > 

</ListView> 

</LinearLayout> 
+0

你能提供你的意思嗎?或相關的代碼片段? – Ahmad

+0

郵政編碼,我們無法知道您實際上在沒有看到代碼的情況下在做什麼。 – hardartcore

回答

5

就想通了自己:

android:layout_marginTop="?android:attr/actionBarSize" 

佔用的空間。