How to show ViewPager in full screen?

Having the activity containing the ViewPager inside it, is it possible to set the full-screen ViewPager mode (on / false) when it touched one click?

enter image description here

If not, I'm going to start a new action in full screen mode containing another instance of the same ViewPager and manually compromise it with ViewPagers CurrentItem , which will require creating more memory and more objects.

What would be the best approach to implement this feature?

+6
source share
2 answers

David Neto's offer is good.

But . You do not need to set the width and height of the layout of all other views 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 this. If not, set match_parent for them.

+4
source

Perhaps you can set onClickListener to 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, I'm not sure if this is the right way to do this, but I think it will work. Also, this is pseudo code, just to explain the idea, this is not the correct Java code (obviously) :)

+2
source

Source: https://habr.com/ru/post/953490/


All Articles