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

Wrong way of setting ViewPager height #16

Closed
alexrainman opened this issue Jan 10, 2016 · 11 comments
Closed

Wrong way of setting ViewPager height #16

alexrainman opened this issue Jan 10, 2016 · 11 comments

Comments

@alexrainman
Copy link

The way you set the ViewPager height OnMeasure makes the DatePicker move to the left when you touch it.

Replace it with this code:

int height = 0;
for(int i = 0; i < getChildCount(); i++) {
    View child = getChildAt(i);
    child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
    int h = child.getMeasuredHeight();
    if(h > height) height = h;
}

heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);

super.onMeasure(widthMeasureSpec, heightMeasureSpec);

And problem fixed!

@jjobes
Copy link
Owner

jjobes commented Jan 11, 2016

Hey Alex,

Could you please give me some more details about what exactly the error is and how to reproduce it?

I'm not sure what you mean by "makes the DatePicker move to the left when you touch it".

Thanks!

Jason

@alexrainman
Copy link
Author

I updated the library to the latest SDK version. When you touch the DatePicker and change the date, somehow it's height change and, instead of being centered it gets moved to the left (aligned to the left).
I changed the code with the one i provided and the issue is gone :)

@jjobes
Copy link
Owner

jjobes commented Jan 11, 2016

Can you give me the details of the device you saw the error on?

@alexrainman
Copy link
Author

Google Nexus 5 Android 5.1

@jjobes
Copy link
Owner

jjobes commented Jan 12, 2016

I just reproduced it on an emulator and I see what you mean. Let me take a closer look at this and I'll report back later.

@jjobes
Copy link
Owner

jjobes commented Jan 12, 2016

Okay, looks good to me! Did you want to submit a PR or do you just want me to push the changes and give you credit for it in the Changelog?

@alexrainman
Copy link
Author

Just include the fix my friend. The credit is all yours for this amazing library. I migrated it to C# and im using it in Xamarin :)

@jjobes
Copy link
Owner

jjobes commented Jan 12, 2016

Okay, will do! I'm glad you find it useful :)

@alexrainman
Copy link
Author

More than useful. I will include it in a free cross platform component for Xamarin.Forms and of course, give u the credit ;)

@jjobes
Copy link
Owner

jjobes commented Jan 12, 2016

Wow, that sounds great! Best of luck on your project!

@alexrainman
Copy link
Author

Cheers for u 2!

@jjobes jjobes closed this as completed in c9c6e22 Jan 12, 2016
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

2 participants