简体   繁体   English

如何摆脱ListView布局中的黑色行

[英]How to get rid of black rows in ListView layout

does someone know how to get rid of black rows in ListView, please have a look on the screenshot. 有人知道如何摆脱ListView中的黑行,请看一下屏幕截图。

替代文字

The xml for each row: 每行的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"
  android:id="@+id/list_view">

    <RelativeLayout
        android:id="@+id/r_layout_for_tasks"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#ffffff">

        <ImageView
            android:id="@+id/icon_image_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/clock"
            android:layout_alignParentLeft="true">
        </ImageView>

        <TextView
            android:id="@+id/task_text_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="10dp"
            android:layout_toRightOf="@id/icon_image_view">
        </TextView>     

        <TextView
            android:id="@+id/time_text_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true">
        </TextView>

    </RelativeLayout>
</LinearLayout>

The activity's layout: 活动的布局:

<?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" 
  android:orientation="vertical"
  android:background="#ffffff">

  <RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:padding="10dp"
    android:background="#ffffff">

    <Button
        android:id="@+id/ok_button"
        android:onClick="onClickOKButton"
        android:text="OK"
        android:layout_width="wrap_content"         
        android:layout_height="wrap_content"
        android:minWidth="60dp"
        android:layout_alignParentRight="true">
    </Button>   

    <EditText
        android:id="@+id/edit_text"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="Task description"
        android:layout_toLeftOf="@id/ok_button">
    </EditText>

  </RelativeLayout>

<ListView
    android:id="@+id/list_view"     
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp">
</ListView>

</LinearLayout>

Have a look at the android:divider attribute to set in the XML layout. 看一下在XML布局中设置的android:divider属性。 You can set it to the same color as the listview background. 您可以将其设置为与列表视图背景相同的颜色。

Hi you can change the listview separator height and color. 您好,您可以更改列表视图分隔符的高度和颜色。

<ListView 
    android:id="@+id/android:list"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:divider="#FFCC00"
    android:dividerHeight="4px"/>

您可以将高度和颜色设置为listview的divider属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM