0

I have a question about viewpager. Is that possible to mix portrait and landscape orientation in one viewpager? To be specific, some of the pages are in portrait orientation while other pages are in landscape orientation.

Thanks.

Peilin Yang
  • 75
  • 1
  • 6

1 Answers1

0

you can override the method getWidth(int) from the adapter to change the width of each page and with that, changing their proportions.

Budius
  • 39,391
  • 16
  • 102
  • 144
  • all right. I will try later and see whether this works. Thanks. – Peilin Yang Feb 25 '13 at 14:31
  • hi Budius. Could you please explain your answer more specifically? By overriding the method getPageWidth(int) I think we can put more pages to one view. But how to change the orientation? – Peilin Yang Feb 25 '13 at 15:11
  • inside your PagerAdapter you will write `@Override public float getPageWidth (int position){ // inside here you return a value between 0.0f and 1.0f meaning 0% to 100% of the ViewPager size }` – Budius Feb 25 '13 at 15:13
  • I know this function is used when you want to show multiple pages in one view. But my question is I want to mix the portrait and landscape orientation. Is that clear? – Peilin Yang Feb 25 '13 at 15:42
  • oohhh, I was understand something different when u said Portrait and Landscape, I thought about simply changing the size of the view (so their proportion is that. You want to actually inflate a layout rotated 90 degrees? If that is, I don't think it's possible or at least not easily achievable. – Budius Feb 25 '13 at 15:46
  • It is fine:). Thanks anyway. – Peilin Yang Feb 25 '13 at 15:49