Thursday 2 April 2015

Android Material Light (android:Theme.Material.Light) Tutorial


Android L comes with alots of enhancements, One of them is Material design. Now we no longer need to depend on resources for handling action bar designs and all.Without talking much i should share new material designs concept which works with Android L.
   

Structure for values folders goes like this here : 





    Follow these steps and give a new look to your app :
 

1. Inside values-v21 folder in Resources : 

 styles.xml : 


<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="AppTheme" parent="android:Theme.Material.Light">
        <item name="android:colorPrimary">@color/primary</item>
        <item name="android:colorPrimaryDark">@color/primary_dark</item>
        <item name="android:colorAccent">@color/accent</item>
        <item name="android:textColorPrimary">@color/text_primary</item>
        <item name="android:textColor">@color/text_secondary</item>
        <item name="android:navigationBarColor">@color/primary_dark</item>
        <item name="android:windowBackground">@color/window_background</item>
    </style>
</resources>


2. Inside values folder :

 styles.xml : Define colors as you need

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <color name="primary">#673ab7</color>
    <color name="primary_dark">#512da8</color>
    <color name="accent">#ffc400</color>
    <color name="text_primary">#D9FFFFFF</color>
    <color name="text_secondary">#D9000000</color>
    <color name="window_background">#ff0000</color>

</resources>


Define your java Class with xml layout with full functionalities.

To play with material designs you just need to work on these two files.
 I've included style in values-v21 as support is not available for lower sdk's as it throws an error  which say android:Theme.Material.Light requires API 21.


Output  With Color Clarifications here :







 
    

No comments:

Post a Comment