What is the best way to bring Material design to the preferences using AppCompat? I've been reading some questions and the main points seem to be:
The official guidelines suggest avoiding PreferenceActivity
if working for API>11 (and I am). Instead one should use PreferenceFragment
s;
Using PreferenceActivity would be bad also because you can't extend both PreferenceActivity
and ActionBarActivity
;
You might use a general ActionBarActivity
and load PreferenceFragment
(API>11) into it. This way preference widgets loaded from resources gets tinted by AppCompat, but that's not true for any widget (see here );
With the suggested solution, anyway, the whole UI look isn't quite Material (see image on Android 4.2), even if inheriting from AppCompat theme.
Another way could be to extend a PreferenceActivity
(API>1). As said, you won't extend ActionBarActivity
but just inherit AppCompat theme.
Last, you could just make your own Activity extending ActionBarActivity
, and deal with widgets, layouts, margins, SharedPreferences yourself.
At the moment I am not aware of a working solution. I've seen some discussion going on in a Chris Banes post introducing Material, but no solution was suggested. I'm asking:
I'm using AndroidDeveloperLB/MaterialPreferenceLibrary
in my projects.
Easy to install. Import
Easy to use. Sample
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With