BamsBamx
BamsBamx

Reputation: 4256

androidx: SwitchPreference VS SwitchPreferenceCompat

The Androidx Preference library offers, amongst others, two classes for implementing a SwitchPreference in Settings screens:

  1. SwitchPreference
  2. SwitchPreferenceCompat

Both implementations in the AOSP source code at the time of writting this question (AOSP Androidx SwitchPreference and AOSP Androidx SwitchPreferenceCompat) looks mostly the same except for some syleables, etc...

So my question is which one do we have to use, considering compatibility with possible future changes of their implementation

Upvotes: 6

Views: 2206

Answers (1)

CrazyBoyFeng
CrazyBoyFeng

Reputation: 41

The Switch widget is the only difference between them.

In API 21 and above, they are the same, because the system will automatically override the classic widgets with the material style.

See also: Switch vs. SwitchCompat

Upvotes: 1

Related Questions