0

I have a preference screen, and I'm trying to get rid of the overScroll. I have tried bunch of different things as mentioned in other stackoverflow posts, but couldn't get disable the overScroll glow. Here is what I tried:

<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:overScrollMode="never"
    android:fadingEdge="none"
    style="@style/PreferenceScreenStyle">

    <androidx.preference.PreferenceCategory android:title="@string/control_file_settings"
    app:iconSpaceReserved="false">

        <androidx.preference.SwitchPreference
            android:key="key"
            android:title="title"
            android:defaultValue="false"
            app:iconSpaceReserved="false"/>
        .
        . 
        .
    </androidx.preference.PreferenceCategory>
    .
    .
    .
</androidx.preference.PreferenceScreen>

Below is in my styles.xml

<style name="PreferenceScreenStyle" parent="@style/PreferenceThemeOverlay.v14.Material">
    <item name="android:scrollViewStyle">@style/CustomScrollView</item>
    <item name="android:listViewStyle">@style/CustomListView</item>
</style>

<style name="CustomScrollView" parent="android:Widget.ScrollView">
    <item name="android:overScrollMode">never</item>
    <item name="android:fadingEdge">none</item>
</style>

<style name="CustomListView" parent="android:Widget.ListView">
    <item name="android:overScrollMode">never</item>
    <item name="android:fadingEdge">none</item>
</style>

Preference Fragment

Overscroll glow

3 Answers3

3

In your fragment "Fragment : PreferenceFragmentCompat()", add "listView.overScrollMode = View.OVER_SCROLL_NEVER" like:

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        listView.overScrollMode = View.OVER_SCROLL_NEVER
}
Taras
  • 31
  • 3
0

Just add these 2 lines to your onCreate method on your SettingsActivity:

ListView list = findViewById(android.R.id.list);
list.setOverScrollMode(ListView.OVER_SCROLL_NEVER);
Mohammad Zarei
  • 1,773
  • 14
  • 33
  • Can you please explain your answer? I have a fragment, and I don't have a view with that Id. Nevertheless, and placed the code in onCreateView, but findViewById returned null. I have attached a screenshot in the question describing my problem – Sri Harsha Arangi Feb 16 '19 at 13:47
  • Here it is: https://github.com/sriharshaarangi/BatteryChargeLimit/blob/master/app/src/main/java/com/slash/batterychargelimit/settings/PrefsFragment.kt – Sri Harsha Arangi Feb 17 '19 at 03:01
0

This is quite similar to the other answers here, but a bit more complete, especially for those who are still using PreferenceFragment (instead of AndroidX's PreferenceFragmentCompat).

You need to override onViewCreated and use View.findViewById() to get the ListView object:

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // Remove over-scroll effect
    ListView list = view.findViewById(android.R.id.list);
    if (list != null) {
        list.setOverScrollMode(ListView.OVER_SCROLL_NEVER);
    }
}