Dot indicator resets to the first page after the activity is rotated
See original GitHub issueAs the title states. I set the ViewPager2 object for the SpringDotsIndicator in the onCreate() method of my activity, and don’t do anything else with the SpringDotsIndicator:
@Override
protected void onCreate(final Bundle savedInstanceState) {
...
final ViewPager2 viewPager = findViewById(R.id.tutorial_pager);
final FragmentStateAdapter pageAdapter = new MyPageAdapter(this);
viewPager.setAdapter(pageAdapter);
final SpringDotsIndicator dotsIndicator = (SpringDotsIndicator) findViewById(R.id.spring_dots_indicator);
dotsIndicator.setViewPager2(viewPager);
...
It behaves correctly normally. However, if I’m on e.g. my third fragment and rotate the screen, when the activity is recreated the fragment shown in the new orientation is still the third one, but the dot indicates that we are on the first fragment.
As soon as I slide the fragment slightly the dot catches up and goes to the correct position.
Is this a bug or am I missing some code in order to handle these cases?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Losing data when rotate screen - android - Stack Overflow
By default, when the screen is rotated your Activity is killed and restarted. To make sure no data is lost, you need to...
Read more >The activity lifecycle | Android Developers
A user expects an activity's UI state to remain the same throughout a configuration change, such as rotation or switching into multi-window ...
Read more >Surviving Configuration Changes in Android
When you rotated the screen, the app lost the count data because it recreated the activity to adapt to the new orientation. Your...
Read more >ViewPager with FragmentPagerAdapter - CodePath Cliffnotes
The first approach is to have the page display a fragment container that switches between multiple child content fragments as outlined in this...
Read more >Handling Orientation Changes on Android - Medium
When you rotate your device and the screen changes orientation, Android usually destroys your application's existing Activities and Fragments and recreates ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hello @nachogoro 👋 I am sorry for this very late reply, but this issue will be fixed in the coming
4.3versionHello, thanks for your contribution ! This issue is now fixed in the new version
4.3Thanks 🔥