How can I show a ViewPager in fullscreen mode?
Asked Answered
K

2

7

By having an activity which contains a ViewPager inside of it, is it possible to set that ViewPager fullscreen (on/false) when it is touched by a single tap?

enter image description here

If not, I am going to start a new activity in fullscreen containing another instance of the same ViewPager and manually sincronize both ViewPagers CurrentItem which will require more memory and more objects to be instantiated.

What would be the best approach to implement this feature?

Kissie answered 9/9, 2013 at 14:8 Comment(0)
M
5

David Neto's suggestion is good.

But: You don't need to set the Layout width and heigth of all other Views to to 0.

What you need to do:

  • Set the Visibility of all other Views to View.GONE, which is much easier

If your ViewPager has "match_parent" properties for width and height, than thats it. If not, set them to "match_parent".

Micropyle answered 9/9, 2013 at 14:37 Comment(0)
C
3

Maybe you could set an onClickListener on the ViewPager to do something like this:

if flag == 0 {
    set the other Views surrounding the ViewPager layout_width and layout_height to 0dp;
    set the ViewPager layout_width and layout_height to 0dp AND layout_weight to 1;
    flag = 1;
}
elseif(flag == 1) {
    set other Views layout_width and layout_height to their normal values;
    set the ViewPager layout_width and layout_height to their normal values also;
    flag = 0;
}

Maybe this helps, not sure if it's the most correct way to do it but I think it will work. Also, this is pseudo code, just to explain the idea, it's not proper Java code (obviously) :)

Comatulid answered 9/9, 2013 at 14:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.