Android-MaterialPreference


Source link: https://github.com/jenzz/Android-MaterialPreference

DEPRECATED

Android-MaterialPreference is deprecated. No more development will be taking place.

Use Google's official support libraries instead com.android.support:preference-v7 and com.android.support:preference-v14.

If you need some assistance in building a fully Material Design settings screen, here is a great series of blog articles on this topic:
Building an Android Settings Screen (Part 1) - How to Create and Fix the Overview Screen
Building an Android Settings Screen (Part 2) - How to Create and Fix the Dialogs
Building an Android Settings Screen (Part 3) - How to Create Custom Preferences
Building an Android Settings Screen (Part 4) - How to Use a Custom Layout for the Preference Fragment

Android - MaterialPreference

Screenshots

  • Here's a side-by-side comparison with a native Lollipop preference:

Usage

In your settings XML file that describes your preferences (must be located in res/xml/ folder) just use the custom implementations like this:

<com.jenzz.materialpreference.PreferenceCategory
android:title="Material Category">
 <com.jenzz.materialpreference.Preference
  android:title="Material Preference"
  android:summary="Material Summary" />
 <com.jenzz.materialpreference.CheckBoxPreference
  android:title="Material CheckBoxPreference"
  android:summaryOn="Material CheckBox Summary On"
  android:summaryOff="Material CheckBox Summary Off" />  </com.jenzz.materialpreference.PreferenceCategory>

That's it. You can use all the attributes you know from the original preferences.

You're probably wondering why there are only Material Design versions of Preference, PreferenceCategory and CheckBoxPreference. Where are ListPreference, EditTextPreference, etc? I don't use them. Instead I just show a simple Preference and display a Material Design dialog when the user selects it. I highly recommend using the material-dialogs library for that.

Theming

  • On Lollipop, the preference color is derived from the android:colorAccent attribute of your app theme.
  • If you're using AppCompat, it is inherited from the colorAccent attribute.
  • If you want a totally different color for your preferences (why would you?), you can still override it in your app theme like this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="mp_colorAccent">#bada55</item> </style>

Also note that the Activity hosting your preferences screen must extend ActionBarActivity in order for the CheckBox tinting to work. The easiest solution to accomplish that is to delegate all your preferences logic (including the inflation) to a PreferenceFragment just like it is done in the sample project.

Example

Check out the sample project for an example implementation.

Download

Grab it via Gradle:

compile 'com.jenzz:materialpreference:1.3'

License

This project is licensed under the MIT License.

Resources

Caesar is a tiny Java library that allows to create an asynchronous proxy-version of some synchronous bean. It means that you can still think in terms of your service/bean/object and use its methods instead of writing concurrency code.

This library allows you to easily create a socket bluetooth connection for multiple android devices with one server and 7 clients max.

Solid is an Android library for data handling.

It provides:

  • SolidList - an immutable, parcelable collection.
  • Lightweight and composable data streams.
  • Primitive array / wrapped array converters.
  • Data analysis algorithms.

A velocimeter View for Android.

Typekit is a library that help you quick change default font of your android application. You don't need to add any custom view or tag to your current xml layout file. You make a quick config in your application class and change the font that you need specific for a style.

log

Log is a super-simple drop-in replacement for android.util.Log that can also be used in normal Java projects.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes