4

I'm running into a weird issues with Android's ViewPager from the support library.

I have my ViewPager set to show a small part of the next fragment. It works and all, except sometimes the left view doesn't resize the way it's supposed to and therefore overlaps with the next fragment. This happens to me approximately 40% of the time I run the app, with the exact same code so it's random...

What I Want Success

What I Sometimes Get Fail

I'm not sure if it matters but I used this solution to fix my ViewPager's wrap_content height and I used this solution to get my ViewPager to scale fragments down to 90% width. Basically just this for scaling:

@Override
public float getPageWidth(int position) {
    return 0.9f;
}

How would I need to go about fixing this very annoying bug? Any help is appreciated, thanks.

Community
  • 1
  • 1
Pkmmte
  • 2,822
  • 1
  • 31
  • 41
  • how you solved this issue? I get same bug if I run app 50 times I get once... in view pager 2 at first I am displaying first 2 pages in half portion and then swipe display pages individually, I have used same method(getPageWidth) .I am not getting how to resolve this – M123 Feb 19 '21 at 07:59
  • @Mansi To be honest, I don't remember the exact details. I just know I forked the ViewPager code and made some changes there that fixed it. The fix wasn't in the adapter nor fragments – Pkmmte Feb 23 '21 at 03:46

0 Answers0