ListView分隔符不可见

Van*_*nja 6 android divider

ListActivity使用BaseAdapter的扩展和以下布局:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:orientation="vertical"     
        android:background="@color/application_background_color">

<ListView android:id="@android:id/list" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:drawSelectorOnTop="false"
    android:divider="@drawable/divider"
    android:dividerHeight="2dip" android:clickable="true"
    android:choiceMode="singleChoice"    
    android:cacheColorHint="@color/application_background_color">
</ListView>

   </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

它为行扩展了以下布局:

            <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">

    <TextView android:id="@+id/Row" 
        android:layout_width="fill_parent" android:layout_height="50dip"
        android:textSize="20dip" android:textColor="#000000"
        android:layout_margin="8dip"
        android:gravity="center_vertical"></TextView>

    </LinearLayout>   
Run Code Online (Sandbox Code Playgroud)

drawable/divider.xml目前看起来像这样,但我尝试了所有不同的类型:

    <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="line">
      <stroke android:color="#FF000000">
      </stroke>
    </shape>    
Run Code Online (Sandbox Code Playgroud)

如果我从图像中读取可绘制的图像就可以了.当我将drawable定义为.xml文件时,为什么它不起作用?

更新:
代码遵循与Android Developer示例中的EfficientAdapter相同的模式:http:
//developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List14.html

paw*_*eba 2

下面的代码对我有用:

列表布局:

<ListView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/list"
    android:cacheColorHint="@android:color/transparent"
    android:background="@android:color/transparent"
    android:textFilterEnabled="false"
    style="@style/ListDivider"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
</ListView>
Run Code Online (Sandbox Code Playgroud)

样式.xml

<resources>
    <style name="ListDivider">
        <item name="android:divider">@drawable/my_shape</item>
        <item name="android:dividerHeight">5dp</item>
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

我的形状:

    <shape
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
        <padding
            android:top="2dp"
            android:left="2dp"
            android:right="2dp"
            android:bottom="2dp" />
        <corners
            android:radius="5dp" />
        <solid
            android:color="@android:color/white" />
    </shape>
Run Code Online (Sandbox Code Playgroud)