如何更改 Android ListView 分隔线的颜色? [英] How to change color of Android ListView separator line?

查看:36
本文介绍了如何更改 Android ListView 分隔线的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变 ListView 分隔线的颜色.任何帮助将不胜感激.

I want to change color of ListView separator line. Any help would be appreciated.

推荐答案

您可以使用 android:divider="#FF0000" 在布局 xml 文件中设置此值.如果您要更改颜色/可绘制对象,则还必须设置/重置分隔线的高度.

You can set this value in a layout xml file using android:divider="#FF0000". If you are changing the colour/drawable, you have to set/reset the height of the divider too.

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

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

</LinearLayout>

这篇关于如何更改 Android ListView 分隔线的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆