The click area of the listView settings part is highlighted

When using listView to develop, you need to click on the item on the listView. Sometimes we don’t need to highlight the entire item, but only the part that you click. At this time, you need to implement an interface SelectionBoundsAdjuster and override the adjustListItemSelectionBounds method.

@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;
    }
}

By reassigning bounds, the desired click area can be highlighted

Guess you like

Origin blog.csdn.net/u010471406/article/details/94717050