Use elevation for dynamic shadows
Bug: 15550085
Change-Id: I21839913551cd7bbbab0b3ab22a708a09e7b6200
diff --git a/res/drawable/display_shadow.xml b/res/drawable/display_shadow.xml
deleted file mode 100644
index e68b63d..0000000
--- a/res/drawable/display_shadow.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:angle="90"
- android:startColor="@android:color/transparent"
- android:endColor="#33000000" />
-</shape>
\ No newline at end of file
diff --git a/res/drawable/pad_page_shadow.xml b/res/drawable/pad_page_shadow.xml
deleted file mode 100644
index 4cd079b..0000000
--- a/res/drawable/pad_page_shadow.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:startColor="@android:color/transparent"
- android:endColor="#33000000" />
-</shape>
\ No newline at end of file
diff --git a/res/layout/activity_calculator_land.xml b/res/layout/activity_calculator_land.xml
index 8a1fac2..1fe12db 100644
--- a/res/layout/activity_calculator_land.xml
+++ b/res/layout/activity_calculator_land.xml
@@ -15,21 +15,21 @@
limitations under the License.
-->
-<RelativeLayout
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<include
- android:id="@+id/display"
layout="@layout/display"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_below="@id/display">
+ android:layout_height="0dip"
+ android:layout_weight="1">
<include layout="@layout/pad_numeric" />
<include layout="@layout/pad_operator_two_col" />
@@ -37,8 +37,4 @@
</LinearLayout>
- <View
- style="@style/DisplayShadowStyle"
- android:layout_below="@id/display" />
-
-</RelativeLayout>
+</LinearLayout>
diff --git a/res/layout/activity_calculator_port.xml b/res/layout/activity_calculator_port.xml
index 975c4a7..605753e 100644
--- a/res/layout/activity_calculator_port.xml
+++ b/res/layout/activity_calculator_port.xml
@@ -15,13 +15,13 @@
limitations under the License.
-->
-<RelativeLayout
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<include
- android:id="@+id/display"
layout="@layout/display"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@@ -29,8 +29,8 @@
<com.android.calculator2.CalculatorPadViewPager
android:id="@+id/pad_pager"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_below="@id/display">
+ android:layout_height="0dip"
+ android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
@@ -41,19 +41,8 @@
</LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <View style="@style/PadPageShadow" />
- <include layout="@layout/pad_advanced" />
-
- </LinearLayout>
+ <include layout="@layout/pad_advanced" />
</com.android.calculator2.CalculatorPadViewPager>
- <View
- style="@style/DisplayShadowStyle"
- android:layout_below="@id/display" />
-
-</RelativeLayout>
+</LinearLayout>
diff --git a/res/layout/activity_calculator_tablet_port.xml b/res/layout/activity_calculator_tablet_port.xml
index d5a99db..cf4b146 100644
--- a/res/layout/activity_calculator_tablet_port.xml
+++ b/res/layout/activity_calculator_tablet_port.xml
@@ -15,36 +15,24 @@
limitations under the License.
-->
-<RelativeLayout
+<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<include
- android:id="@+id/display"
- layout="@layout/display"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <LinearLayout
+ layout="@layout/display"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_below="@id/display"
- android:orientation="vertical">
+ android:layout_height="wrap_content" />
- <include layout="@layout/pad_advanced" />
+ <include layout="@layout/pad_advanced" />
- <LinearLayout style="@style/PadLinearLayoutStyle">
+ <LinearLayout style="@style/PadLinearLayoutStyle">
- <include layout="@layout/pad_numeric" />
- <include layout="@layout/pad_operator_two_col" />
-
- </LinearLayout>
+ <include layout="@layout/pad_numeric" />
+ <include layout="@layout/pad_operator_two_col" />
</LinearLayout>
- <View
- style="@style/DisplayShadowStyle"
- android:layout_below="@id/display" />
-
-</RelativeLayout>
+</LinearLayout>
diff --git a/res/layout/display.xml b/res/layout/display.xml
index 2ca5003..0e1d978 100644
--- a/res/layout/display.xml
+++ b/res/layout/display.xml
@@ -17,9 +17,11 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/display"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:background="@color/display_background_color">
+ android:background="@color/display_background_color"
+ android:elevation="4dip">
<com.android.calculator2.CalculatorEditText
android:id="@+id/formula"
diff --git a/res/values-port/dimens.xml b/res/values-port/dimens.xml
index bf71f71..dd66e9a 100644
--- a/res/values-port/dimens.xml
+++ b/res/values-port/dimens.xml
@@ -18,6 +18,6 @@
<resources>
<!-- The margin between the pad pages when displayed using a view pager. -->
- <dimen name="pad_page_margin">-32dip</dimen>
+ <dimen name="pad_page_margin">-24dip</dimen>
</resources>
diff --git a/res/values-port/styles.xml b/res/values-port/styles.xml
index b998d62..c14558b 100644
--- a/res/values-port/styles.xml
+++ b/res/values-port/styles.xml
@@ -62,6 +62,7 @@
</style>
<style name="PadLayoutStyle.Advanced">
+ <item name="android:elevation">4dip</item>
<item name="android:paddingTop">12dip</item>
<item name="android:paddingBottom">20dip</item>
<item name="android:paddingStart">20dip</item>
@@ -88,10 +89,4 @@
<item name="android:paddingEnd">24dip</item>
</style>
- <style name="PadPageShadow">
- <item name="android:layout_width">8dip</item>
- <item name="android:layout_height">match_parent</item>
- <item name="android:background">@drawable/pad_page_shadow</item>
- </style>
-
</resources>
\ No newline at end of file
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 06f2b8a..217df5d 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -32,12 +32,6 @@
<item name="android:gravity">bottom|end</item>
</style>
- <style name="DisplayShadowStyle">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">8dip</item>
- <item name="android:background">@drawable/display_shadow</item>
- </style>
-
<style name="PadButtonStyle" parent="@android:style/Widget.Material.Light.Button.Borderless">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
diff --git a/src/com/android/calculator2/CalculatorPadViewPager.java b/src/com/android/calculator2/CalculatorPadViewPager.java
index bc015f2..014df9c 100644
--- a/src/com/android/calculator2/CalculatorPadViewPager.java
+++ b/src/com/android/calculator2/CalculatorPadViewPager.java
@@ -48,7 +48,7 @@
@Override
public float getPageWidth(int position) {
- return position == 1 ? 0.8f : 1.0f;
+ return position == 1 ? 7.0f / 9.0f : 1.0f;
}
};