GithubHelp home page GithubHelp logo

tohateam / materialsettings-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from davcpas1234/materialsettings

0.0 1.0 0.0 1.4 MB

The open repository with a global support for Android 5 Toolbar within any Settings Activity

Java 100.00%

materialsettings-1's Introduction

Banner #MaterialSettings

The open repository with a global support for Android 5 Toolbar within any Settings Activity (PreferenceActivity), compatible with API 10 and above.

##Sample App

">https://play.google.com/store/apps/details?id=uk.verscreative.materialsettings)-->

Being Updated! - Watch this space :)

##IMPORTANT - Compatibility ###Element Tinting In order to mimic (material-like) element tinting on pre-L devices utilise the following code:

@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
    // Allow super to try and create a view first
    final View result = super.onCreateView(name, context, attrs);
    if (result != null) {
        return result;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        // If we're running pre-L, we need to 'inject' our tint aware Views in place of the
        // standard framework versions
        switch (name) {
            case "EditText":
                return new AppCompatEditText(this, attrs);
            case "Spinner":
                return new AppCompatSpinner(this, attrs);
            case "CheckBox":
                return new AppCompatCheckBox(this, attrs);
            case "RadioButton":
                return new AppCompatRadioButton(this, attrs);
            case "CheckedTextView":
                return new AppCompatCheckedTextView(this, attrs);
        }
    }

    return null;
}

Remember: Import the appcompt-v7 library in your app.gradle:
compile 'com.android.support:appcompat-v7:22.2.0'

###Gingerbread

In order to handle nested PreferenceScreens correctly onConfigurationChanged() must be overriden in your SettingsActivity as below:

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
}

and so this code is called, add the following to your SettingsActivity declaration in your AndroidManifest.xml:

android:configChanges="keyboard|keyboardHidden|orientation|screenSize"

Full Example:

<activity
    android:name=".SettingsExampleActivity"
    android:label="@string/title_activity_settings_example"
    android:theme="@style/AppTheme.NoActionBar"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

Thanks to @hclemens for indentifying this.

###Toolbar Shadow To simulate the elevation of the Toolbar on pre-L devices, utilise the following code:

<android.support.design.widget.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

   <android.support.v7.widget.Toolbar
       .../>

</android.support.design.widget.AppBarLayout>

Remember: Import the Design library in your app.gradle:
compile 'com.android.support:design:22.2.0'

materialsettings-1's People

Contributors

davcpas1234 avatar kosratdev avatar 1priyank1 avatar

Watchers

 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.