Skip to content
This repository was archived by the owner on May 1, 2021. It is now read-only.

Commit c82c44a

Browse files
author
AndroidDeveloperLB
committed
using elevation instead of shadow for the PreferenceActivity, in case it's Lollipop and above.
1 parent 834bd09 commit c82c44a

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Demo/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.alertdialogpro.demo"
4-
android:versionCode="1"
4+
android:versionCode="1"
55
android:versionName="1.0" >
66

77
<uses-sdk

MaterialStuffLibrary/src/com/lb/material_stuff_library/MaterialPreferenceActivity.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package com.lb.material_stuff_library;
22
import android.app.Activity;
3+
import android.os.Build.VERSION;
4+
import android.os.Build.VERSION_CODES;
35
import android.os.Bundle;
46
import android.preference.PreferenceActivity;
7+
import android.support.v4.view.ViewCompat;
58
import android.support.v7.widget.Toolbar;
69
import android.util.TypedValue;
710
import android.view.View;
11+
import android.view.ViewGroup;
812
import com.alertdialogpro.R;
913

1014
public 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

Comments
 (0)