2

I am just about to create Android application and I need to calculate left and right padding of ViewPager so I can show three fragment items in it, one to be centered and the other two to be from left and right side of the first one.

If I set some fixed values of padding it looks good on one device, but on the other I cannot see all three items, but only one OR if I set padding to be too big then my ViewPager overlap items. So I need to calculate it depending on screen size.

I have found this question but it does not solve my problem.

The arrangement of the fragments should be like on the picture enter image description here

Can you please help me to solve this problem?

thanks in advance

Community
  • 1
  • 1
svarog
  • 688
  • 1
  • 12
  • 29

2 Answers2

0

you are looking for Carousel View ( so you can make your ViewPager looks like the one in the Picture)

I think there is a lot of libraries will help you to do this ;

https://github.com/codepath/android_guides/wiki/ViewPager-with-FragmentPagerAdapter

https://github.com/clkasd/CarouselViewProject

this question would be helpful :

How to create a carousel using viewpager and fragmentStatePager Adapter

Community
  • 1
  • 1
maysara
  • 5,873
  • 2
  • 23
  • 34
  • Thank you for your time and effort. I hope so that this will work. I am trying to implement this using Xamarin Android... Eventually I will let you know the outcome. Thanks again! – svarog Aug 09 '16 at 10:07
  • Hi, I have tried but unfortunately there is no "net.infratek.CarouselView.MyLinearLayout" in Android Xamarin and I cannot use this. Do you have any other idea how can I solve the problem? thank you! – svarog Aug 09 '16 at 12:45
0

I have tried to setup negative margins in order to display 3 fragments in viewpager, but unfortunately I didn't achieve desired look - negative margins don't work for Android Xamarin and only one fragment is shown on the screen.

So far, the only way is, depending on some constant, to set left and right padding.

svarog
  • 688
  • 1
  • 12
  • 29