google / flexbox-layout

Flexbox for Android
Apache License 2.0
18.22k stars 1.79k forks source link

FlexboxLayoutManager.computeScrollOffset(); It is wrong to be equal to 0 #610

Open shenliangshanghai opened 1 year ago

shenliangshanghai commented 1 year ago

Issues and steps to reproduce

*Why is flexboxmanager. Computescrolloffset() equal to 0 when only half of the first line is visible;I can't judge whether recyclerView.canScrollVertically() can continue to slide

Expected behavior

Version of the flexbox library

*1.1.1 - 3.0.0

Link to code

//bottomSheetBehavior.java if (!target.canScrollVertically(-1)) { if (newTop <= collapsedOffset || hideable) { if (!isDraggable) { // Prevent dragging return } consumed[1] = dyUnconsumed ViewCompat.offsetTopAndBottom(child, -dyUnconsumed) setStateInternal(STATE_DRAGGING) } else { consumed[1] = currentTop - collapsedOffset ViewCompat.offsetTopAndBottom(child, -consumed[1]) setStateInternal(STATE_COLLAPSED) } }

wojiaosuxiaobai commented 7 months ago

I have the same issue.

public static boolean isFirstViewCovered(FlexboxLayoutManager flexboxLayoutManager) {
        try {
            if (flexboxLayoutManager.findFirstVisibleItemPosition() == 0) {
                View firstView = flexboxLayoutManager.findViewByPosition(0);
                if (firstView != null) {
                    return isViewCoveredByParent(firstView);
                }
            }
        } catch (Throwable e) {
            Log.e("isFirstViewCovered", "error: " + e.getMessage());
        }

        return false;
    }

I made a compromise with this method