Question

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?

Was it helpful?

Solution

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".

OTHER TIPS

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) :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top