DevsmartLib-Android icon indicating copy to clipboard operation
DevsmartLib-Android copied to clipboard

if ChildView Width > Screen width then shows half view

Open nixit28 opened this issue 12 years ago • 8 comments

Hi, I have implemented Horizontal List view in to my application, It works great. But I have encountered one problem which is if child view's width exceeds from the screen width it shows the view till the screen size rest is cutoff from the screen.

any idea how to solve this problem

Thanks

nixit28 avatar Oct 20 '12 08:10 nixit28

No sorry, I have not had that problem. If you figure out how to solve it I would love a git push request. Thanks.

On Sat, Oct 20, 2012 at 4:37 AM, Nixit Patel [email protected]:

Hi, I have implemented Horizontal List view in to my application, It works great. But I have encountered one problem which is if child view's width exceeds from the screen width it shows the view till the screen size rest is cutoff from the screen.

any idea how to solve this problem

Thanks

— Reply to this email directly or view it on GitHubhttps://github.com/dinocore1/DevsmartLib-Android/issues/20.

dinocore1 avatar Oct 22 '12 17:10 dinocore1

noticed same thing periodically on emulator 2.1 when scrolling device-2012-12-11-112221

look at the left side. The most left thumb (serif) is partially visible. The ship thumb should not be on the screen anymore

httpdispatch avatar Dec 11 '12 08:12 httpdispatch

Tested this a little bit more. Seems that the view is not invalidated properly in some cases on android 2.1. Even if i force call invalidate some regions show invalid information.

httpdispatch avatar Dec 11 '12 10:12 httpdispatch

@httpdispatch also on my 4.4 kitkat ,, any solutions ??!! thanks , device-2014-02-12-111809

kazaky avatar Feb 12 '14 09:02 kazaky

@kazaky How i remember i've fixed that issue by modifying method measureChild

private void measureChild(final View child) {
        child.measure(MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.UNSPECIFIED),
                MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.AT_MOST));
    }

httpdispatch avatar Feb 12 '14 10:02 httpdispatch

thanks@httpdispatch for the reply there is no measureChild(final View child)

only this one , with different parameters ,, & i tried to edit it as u said , not working!

private void addAndMeasureChild(final View child, int viewPos) {
    LayoutParams params = child.getLayoutParams();
    if (params == null) {
        params = new LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.FILL_PARENT);
    }

    addViewInLayout(child, viewPos, params, true);
    child.measure(
            MeasureSpec.makeMeasureSpec(getWidth(), MeasureSpec.AT_MOST),
            MeasureSpec.makeMeasureSpec(getHeight(), MeasureSpec.AT_MOST));
}

kazaky avatar Feb 12 '14 10:02 kazaky

I've did a couple of bugfixes so don't remember which one fixed the issue. You may try my bugfixes version of HorizontalListView here https://gist.github.com/httpdispatch/8953995

Also please note that you should explicitly set Layout width for you child views to be larger than screen size to overcome the issue

httpdispatch avatar Feb 12 '14 11:02 httpdispatch

i'll check that , Thanks Sir :D

kazaky avatar Feb 12 '14 16:02 kazaky