zoukankan      html  css  js  c++  java
  • 如何去掉ListView底部的ListDivider

    首先,我们先来了解ListView的两个属性以及它们的API解析

    android:headerDividersEnabled:  When set to false, the ListView will not draw the divider after each header view. [boolean]

    android:footerDividersEnabled:   When set to false, the ListView will not draw the divider before each footer view. [boolean]

    可见,这里两个属性都只对HeaderView和FooterView有效,如果你没有在ListView加入HeaderView或者FooterView,无论设置什么值,都是没有作用的。

    那在我们该怎么让ListView的底部Divider消失呢,那就得在ListView的layoutHeight上做文章了。

    通过对ListView的源码分析,我们发现,所有的分割线都是通过画一个很窄的矩形实现的,但是在给每一行画分割线之前,ListView都会判断当前行的底部位置是否到达或者超出了ListView的底部,如果到达了,那么就不会画这条分割线。

    所以,如果ListView的高度是fill_parent,那么当Item很少,而没有能填满ListView的高度的时候,底部就会出现分割线。反之,如果ListView的高度是wrap_content,那么ListView的高度就是随着Item的增多而变高的,最后一行的Item始终是达到了ListView的底部,也就不会出现分割线了。

  • 相关阅读:
    脚本添加crontab任务
    docker mysql8 注意
    使用 logrotate 清理日志
    腾讯云cos对象在线显示
    快速部署私人git服务--基于docker化Gogs
    grep 使用
    vsftpd 新增虚拟用户
    unistd.h
    ffmpeg
    H264视频压缩算法
  • 原文地址:https://www.cnblogs.com/Jingerxin/p/5090951.html
Copyright © 2011-2022 走看看