Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best practice to bring Material look to Preferences using AppCompat?

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 PreferenceFragments;

  • 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:

  • Did some of you succeed in bringing a pure (as possible) Material look to preferences, and how?
  • Will there be improvements in v7 regarding this issue in the future?

like image 930
natario Avatar asked Dec 31 '14 18:12

natario


1 Answers

enter image description here

I'm using AndroidDeveloperLB/MaterialPreferenceLibrary in my projects.

Easy to install. Import
Easy to use. Sample

like image 112
Tomblarom Avatar answered Oct 21 '22 11:10

Tomblarom