I’ve been waiting for such a question. I don’t think you will make the implementation any easier if you, actually, want to have an authorization process. The main objective of using two different fragments(Login / Sign up) is that you don’t really care what’s going on in another fragment. It has its own input fields, you just push any similar logic, which is animation, to the base class (AuthFragment.class). Alright, in case if you want to do this in a single activity, and reusing the input fields for both Login /Sign Up, how do you distinguish when the user has pressed the password field, or any other input for that matter, for Login/Sign Up? Probably you will end up with a lot of if statements in your code. Okay, you can say “ I don’t want to reuse the inputs, we can just have two different layouts as in your example”. In this case, how do you want to switch between those layouts? Are you going to use a ViewFlipper or a ViewSwitcher? The problem here is that we can’t create this gap(a fragment peeking out) with the ViewFlipper or ViewSwitcher. You can write a custom view for that, but is it worth it?:) Just adapt the functionality provided by the PagerAdapter for this purpose, and you get a perfect solution. Implementing this stuff in a single activity will make the activity overstuffed with different responsibilities. If you use fragments for this purpose, you get a perfect separation of concerns. It’s even easier to think about each process (login/sign up) when it’s been wrapped up in a Fragment.
That was a good question! Thank you!:)
