How to add border to listview and different row colors at the same time

前端 未结 1 1633
眼角桃花
眼角桃花 2021-01-16 00:04

I\'m trying to have a border on the outside of my listview and a different color for every other row at the same time

相关标签:
1条回答
  • 2021-01-16 00:22

    Rewrite

    You have obviously read: How do you put a border around a ListView? since you are using the code from the better / more popular answer. But read the bottom answer as well, I had success by adding 2dp padding (the same width as the border.)

      <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/border_listview"
        android:gravity="center_horizontal"
        android:orientation="vertical"
        android:padding="2dp" >
    
        <ListView
            android:id="@+id/listView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:divider="@null"
            android:dividerHeight="0dp" />
    </LinearLayout>
    
    0 讨论(0)
提交回复
热议问题