2

問題與API有關。在API 9+細胞看起來完全是這樣ListView的自定義單元格與API9中的父級寬度不匹配

enter image description here

但是在Android 2.3它看起來像這樣: enter image description here

我找不到這個原因。這裏是我的單元佈局:

<LinearLayout 
    android:id="@+id/cell_container" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="5dp" 
    android:layout_marginLeft="10dp" 
    android:layout_marginRight="10dp" 
    android:layout_marginTop="5dp" 
    android:background="@drawable/rounded_cell" 
    android:orientation="vertical" 
    android:padding="5dp" > 

    ...content here 
</LinearLayout> 

這個名單片段佈局:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/light_gray" > 
    <ListView 
     android:id="@+id/list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:divider="#00000000" 
     android:paddingTop="5dp" > 
    </ListView> 
</FrameLayout> 

的問題是肯定的佈局,因爲它會顯示錯誤即使在Eclipse中的佈局編輯器中。如何使它適用於所有API的9+?

回答

2

我的天啊。它始終是血腥的FrameLayout。我得到了你的建議。不要使用FrameLayout。即使你認爲它適合,不要。它造成了很多麻煩。例如,在這裏,當我將主佈局從FrameLayout更改爲LinearLayout時,它完美地工作!

相關問題