Giter VIP home page Giter VIP logo

android-materialpreference's Introduction

Android - MaterialPreference

Screenshots

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

alt text

Usage

In your settings XML file that describes your preferences (must be located in res/xml/ folder) just use the custom Preference and PreferenceCategory 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.PreferenceCategory>

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

You're probably wondering why there's only a Material Design version of Preference and one for PreferenceCategory. 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>

Example

Check out the sample project for an example implementation.

Download

Grab it via Gradle:

compile 'com.jenzz:materialpreference:1.2'

License

This project is licensed under the MIT License.

android-materialpreference's People

Watchers

James Cloos avatar Justo Miguel Vargas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.