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的底部,也就不会出现分割线了。

  • 相关阅读:
    King's Quest
    JavaScript“并非”一切皆对象
    javascript中的style只能取到在HTML中定义的css属性
    jquery中的$(this)和this
    WEB安全字体(Web Safe Fonts)-网页设计用什么字体兼容性好?
    css各种水平垂直居中
    css绘制各种形状
    css3椭圆运动
    通过时间戳控制类
    js中的面向对象程序设计
  • 原文地址:https://www.cnblogs.com/Jingerxin/p/5090951.html
Copyright © 2011-2022 走看看