0

Has anyone experienced this? When I press on a SwitchPreference, the ScrollView scrolls up. This never happens with any other preferences which include MultiSelectListPreference, Preference, and ListPreference.

Even with blank behavior (a listener has not been registered to the SwitchPreference), a successful toggle always causes the list to scroll up. And after 2 times of toggling it, the erratic scrolling behavior does not occur again until the activity is destroyed.

poetryrocksalot
  • 697
  • 2
  • 10
  • 19
  • https://issuetracker.google.com/issues/36941388 Could this be related? – Zun Jun 27 '19 at 08:23
  • Are you using the AndroidX Preference library? Or is this in the framework `android.preference` library? – Louis Jun 27 '19 at 13:50
  • I am using android.preference (but it is the compat library). The actual preference is SwitchPreferenceCompat. As for the other answer, I don't think it's the same thing I am experiencing. My issue is that when I press a Switch at the bottom, the ScrollView will jump to the top. The other people's issue is that the wrong Switch is being updated because it is sharing the same view. – poetryrocksalot Jun 28 '19 at 00:50
  • My issue does not occur in some devices and emulators, but it does occur on my Nougat phone. I added empty dummy Switches and it does the same thing. – poetryrocksalot Jun 28 '19 at 00:50
  • Are you using the latest version? It is recommended that you migrate over to the AndroidX library in any case, it's the evolution of the original compat libraries. – Louis Jun 28 '19 at 01:08
  • I'm going to migrate to AndroidX and see if this works! – poetryrocksalot Jun 28 '19 at 04:46
  • Migrating to androidx.preference did not fix it. – poetryrocksalot Jun 29 '19 at 02:38
  • Do you have a small sample application you can share? What does your preference xml look like? And what version of androidx are you using? – Louis Jun 29 '19 at 16:18
  • I fixed the problem by removing ScrollView and just using a LinearLayout as the parent for the fragment that hosted the PreferenceScreen/Preferences. Doing this immediately solved the problem. I assumed PreferenceScreen and/or LinearLayout would not have scrollable behavior by default, so I originally used a ScrollView as the parent. But it already works out of the box without having ScrollView as a parent. – poetryrocksalot Jun 30 '19 at 08:17
  • Ohh, yeah - that makes sense :) AndroidX Preferences use a RecyclerView, so scrolling is automatically handled for you. Glad you figured it out! – Louis Jun 30 '19 at 15:37

0 Answers0