Closed alexi190 closed 7 years ago
Did you use the app that I provided?Or you just created your own app with the same implementation? If you have your own app, make sure that you properly handle the activity lifecycle. When you navigate to another screen and then go back to the app, your activity gets recreated(sometimes it doesn't on my phone). I tried the same with my app and everything works fine.
@peswanibros Have you resolved the issue?If so, what was the problem?
@vpaliyX I cloned the project and ran it on emulator and device. Also, I integrated it in my app. The behaviour is same. But I've found the workaround for it. Just comment out line in LoginActivity.
// background.scrollTo(-background.getWidth() / 2, 0);
This may be a issue of the backround scaling and srcolling. I don't know what will be the good solution but it works.
@peswanibros What device did you use to run the app? And what API?(for both an emulator and real device) If you remove this line, the background image will be different. That line just scrolls to the very left of the image, it has noting to do with setting up the fragments. But if it works for you, I'm glad it does.
@vpaliyX OnePlus3, emulator API 24. Even I tried app from play store also. Same is happening. You start the app and press back button and again open the app from App Menu not from recents. Although when I debug the fragments are getting attached to viewpager.
That's a good catch! I just ran the app on a device with API 24 and happened exactly what you said. The fragments are not being shown after the app has been launched from the app menu one more time.
But I've figured this out. The problem here is that I'm trying to initialize the adapter before the ViewPager
has been laid out. In this case when we call the pager.getWidth()
method in the constructor, it returns 0. Which affects the factor
value, it simply turns out to be infinity. As a result, our fragment's width is always zero.
Check out my . The solution is to initialize the adapter after the ViewPager
has been laid out using the ViewPager.post()
method.
I guess the issue has been resolved so I'm closing this.
Thanks for your time and effort really appricated.
Thank you for the issue. I should have definitely tested that on a lower API.
First of all the concept is great. I tried it in my app but when I start LoginActivity at first time it works fine but after that when I press back button and again open LoginActivity AuthFragment i.e Login and Signup fragments do not appear.