listView设置部分点击区域高亮

在使用listView开发的时候,需要点击listView上的item,有时候我们不需要整个item全部高亮,只需要自己点的那一部分高亮,这时候就需要实现一个接口SelectionBoundsAdjuster,重写adjustListItemSelectionBounds方法

@Override
public void adjustListItemSelectionBounds(Rect bounds) {
    if (mAdjustSelectionBoundsEnabled) {
        bounds.top += mBoundsWithoutHeader.top;
        bounds.bottom = bounds.top + mBoundsWithoutHeader.height();
        bounds.left = mBoundsWithoutHeader.left;
        bounds.right = mBoundsWithoutHeader.right;
    }
}

通过给bounds重新赋值,就能实现想要的点击区域高亮

猜你喜欢

转载自blog.csdn.net/u010471406/article/details/94717050
今日推荐