Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HorizontalListView item width incurrent when scroll again and again. and solution. #31

Open
bin-liu opened this issue Apr 15, 2013 · 0 comments

Comments

@bin-liu
Copy link

bin-liu commented Apr 15, 2013

The width value of child view isn't equal with measure of WRAP_CONTENT on showing when scroll at some times.
Reason: get the child view from mRemovedViewQueue lead to use old layoutParam on addAndMeasureChild.
Solution:always get new layoutParam in addAndMeasureChild.

I think is better display that look as same as ListView except direction.
my code:

private void addAndMeasureChild(final View child, int viewPos) {

    LayoutParams params = (LayoutParams) child.getLayoutParams();
        params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
    addViewInLayout(child, viewPos, params, true);  
    int heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight(), 
        MeasureSpec.EXACTLY); 
    int childHeightSpec = ViewGroup.getChildMeasureSpec(heightMeasureSpec,
                getPaddingTop() + getPaddingBottom(), params.height);
    int childWidthSpec = MeasureSpec.makeMeasureSpec(
        params.width > 0 ? params.width : 0, MeasureSpec.UNSPECIFIED);
    child.measure(childWidthSpec, childHeightSpec);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant