diff options
-rw-r--r-- | api/current.txt | 2 | ||||
-rw-r--r-- | core/java/android/app/ActionBar.java | 27 | ||||
-rw-r--r-- | core/java/com/android/internal/app/ToolbarActionBar.java | 10 | ||||
-rw-r--r-- | core/java/com/android/internal/app/WindowDecorActionBar.java | 17 | ||||
-rw-r--r-- | core/res/res/values/attrs.xml | 10 | ||||
-rw-r--r-- | core/res/res/values/styles_material.xml | 1 | ||||
-rw-r--r-- | core/res/res/values/themes_material.xml | 2 |
7 files changed, 68 insertions, 1 deletions
diff --git a/api/current.txt b/api/current.txt index b0e8ef0..ed38885 100644 --- a/api/current.txt +++ b/api/current.txt @@ -3159,6 +3159,7 @@ package android.app { method public abstract deprecated void addTab(android.app.ActionBar.Tab, int, boolean); method public abstract android.view.View getCustomView(); method public abstract int getDisplayOptions(); + method public float getElevation(); method public abstract int getHeight(); method public int getHideOffset(); method public abstract deprecated int getNavigationItemCount(); @@ -3190,6 +3191,7 @@ package android.app { method public abstract void setDisplayShowHomeEnabled(boolean); method public abstract void setDisplayShowTitleEnabled(boolean); method public abstract void setDisplayUseLogoEnabled(boolean); + method public void setElevation(float); method public void setHideOffset(int); method public void setHideOnContentScrollEnabled(boolean); method public void setHomeActionContentDescription(java.lang.CharSequence); diff --git a/core/java/android/app/ActionBar.java b/core/java/android/app/ActionBar.java index 5c98180..b74c824 100644 --- a/core/java/android/app/ActionBar.java +++ b/core/java/android/app/ActionBar.java @@ -993,6 +993,33 @@ public abstract class ActionBar { } } + /** + * Set the Z-axis elevation of the action bar in pixels. + * + * <p>The action bar's elevation is the distance it is placed from its parent surface. Higher + * values are closer to the user.</p> + * + * @param elevation Elevation value in pixels + */ + public void setElevation(float elevation) { + if (elevation != 0) { + throw new UnsupportedOperationException("Setting a non-zero elevation is " + + "not supported in this action bar configuration."); + } + } + + /** + * Get the Z-axis elevation of the action bar in pixels. + * + * <p>The action bar's elevation is the distance it is placed from its parent surface. Higher + * values are closer to the user.</p> + * + * @return Elevation value in pixels + */ + public float getElevation() { + return 0; + } + /** @hide */ public void setDefaultDisplayHomeAsUpEnabled(boolean enabled) { } diff --git a/core/java/com/android/internal/app/ToolbarActionBar.java b/core/java/com/android/internal/app/ToolbarActionBar.java index e8a3f0a..7af52f3 100644 --- a/core/java/com/android/internal/app/ToolbarActionBar.java +++ b/core/java/com/android/internal/app/ToolbarActionBar.java @@ -122,6 +122,16 @@ public class ToolbarActionBar extends ActionBar { } @Override + public void setElevation(float elevation) { + mToolbar.setElevation(elevation); + } + + @Override + public float getElevation() { + return mToolbar.getElevation(); + } + + @Override public Context getThemedContext() { return mToolbar.getContext(); } diff --git a/core/java/com/android/internal/app/WindowDecorActionBar.java b/core/java/com/android/internal/app/WindowDecorActionBar.java index 7bd316f..b5ff0cc 100644 --- a/core/java/com/android/internal/app/WindowDecorActionBar.java +++ b/core/java/com/android/internal/app/WindowDecorActionBar.java @@ -222,6 +222,10 @@ public class WindowDecorActionBar extends ActionBar implements if (a.getBoolean(R.styleable.ActionBar_hideOnContentScroll, false)) { setHideOnContentScrollEnabled(true); } + final int elevation = a.getDimensionPixelSize(R.styleable.ActionBar_elevation, 0); + if (elevation != 0) { + setElevation(elevation); + } a.recycle(); } @@ -236,6 +240,19 @@ public class WindowDecorActionBar extends ActionBar implements } } + @Override + public void setElevation(float elevation) { + mContainerView.setElevation(elevation); + if (mSplitView != null) { + mSplitView.setElevation(elevation); + } + } + + @Override + public float getElevation() { + return mContainerView.getElevation(); + } + public void onConfigurationChanged(Configuration newConfig) { setHasEmbeddedTabs(ActionBarPolicy.get(mContext).hasEmbeddedTabs()); } diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index a4bd526..b4a4098 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -6783,10 +6783,20 @@ <attr name="itemPadding" format="dimension" /> <!-- Set true to hide the action bar on a vertical nested scroll of content. --> <attr name="hideOnContentScroll" format="boolean" /> + <!-- Minimum inset for content views within a bar. Navigation buttons and + menu views are excepted. Only valid for some themes and configurations. --> <attr name="contentInsetStart" format="dimension" /> + <!-- Minimum inset for content views within a bar. Navigation buttons and + menu views are excepted. Only valid for some themes and configurations. --> <attr name="contentInsetEnd" format="dimension" /> + <!-- Minimum inset for content views within a bar. Navigation buttons and + menu views are excepted. Only valid for some themes and configurations. --> <attr name="contentInsetLeft" format="dimension" /> + <!-- Minimum inset for content views within a bar. Navigation buttons and + menu views are excepted. Only valid for some themes and configurations. --> <attr name="contentInsetRight" format="dimension" /> + <!-- Elevation for the action bar itself --> + <attr name="elevation" /> </declare-styleable> <declare-styleable name="ActionMode"> diff --git a/core/res/res/values/styles_material.xml b/core/res/res/values/styles_material.xml index 3880fb3..4623258 100644 --- a/core/res/res/values/styles_material.xml +++ b/core/res/res/values/styles_material.xml @@ -804,6 +804,7 @@ please see styles_device_defaults.xml. <item name="homeLayout">@layout/action_bar_home_material</item> <item name="gravity">center_vertical</item> <item name="contentInsetStart">16dp</item> + <item name="elevation">8dp</item> </style> <style name="Widget.Material.ActionBar.Solid"> diff --git a/core/res/res/values/themes_material.xml b/core/res/res/values/themes_material.xml index 610c8b8..47f3778 100644 --- a/core/res/res/values/themes_material.xml +++ b/core/res/res/values/themes_material.xml @@ -499,7 +499,7 @@ please see themes_device_defaults.xml. <item name="windowFullscreen">false</item> <item name="windowOverscan">false</item> <item name="windowIsFloating">false</item> - <item name="windowContentOverlay">@drawable/ab_solid_shadow_material</item> + <item name="windowContentOverlay">@null</item> <item name="windowShowWallpaper">false</item> <item name="windowTitleStyle">@style/WindowTitle.Material</item> <item name="windowTitleSize">@dimen/action_bar_default_height_material</item> |