11package com .lb .material_stuff_library ;
22import android .app .Activity ;
3+ import android .os .Build .VERSION ;
4+ import android .os .Build .VERSION_CODES ;
35import android .os .Bundle ;
46import android .preference .PreferenceActivity ;
7+ import android .support .v4 .view .ViewCompat ;
58import android .support .v7 .widget .Toolbar ;
69import android .util .TypedValue ;
710import android .view .View ;
11+ import android .view .ViewGroup ;
812import com .alertdialogpro .R ;
913
1014public abstract class MaterialPreferenceActivity extends PreferenceActivity
@@ -25,6 +29,13 @@ protected void onCreate(final Bundle savedInstanceState)
2529 {
2630 super .onCreate (savedInstanceState );
2731 setContentView (R .layout .msl__activity_preference );
32+ if (VERSION .SDK_INT >=VERSION_CODES .LOLLIPOP )
33+ {
34+ _shadowView =findViewById (R .id .msl__shadowView );
35+ final ViewGroup parent =(ViewGroup )_shadowView .getParent ();
36+ parent .removeView (_shadowView );
37+ _shadowView =null ;
38+ }
2839 addPreferencesFromResource (getPreferencesXmlId ());
2940 _toolbar =(Toolbar )findViewById (R .id .msl__toolbar );
3041 _toolbar .setClickable (true );
@@ -50,8 +61,13 @@ private static int getResIdFromAttribute(final Activity activity,final int attr)
5061
5162 protected void setEnabledActionBarShadow (final boolean enable )
5263 {
53- if (_shadowView ==null )
54- _shadowView =findViewById (R .id .msl__shadowView );
55- _shadowView .setVisibility (enable ? View .VISIBLE : View .GONE );
64+ if (VERSION .SDK_INT >=VERSION_CODES .LOLLIPOP )
65+ ViewCompat .setElevation (_toolbar ,enable ? 4 : 0 );
66+ else
67+ {
68+ if (_shadowView ==null )
69+ _shadowView =findViewById (R .id .msl__shadowView );
70+ _shadowView .setVisibility (enable ? View .VISIBLE : View .GONE );
71+ }
5672 }
5773 }
0 commit comments