diff options
author | John Reck <jreck@google.com> | 2017-11-17 15:06:24 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2018-01-31 11:28:11 -0800 |
commit | d8be4a0abe7e2439813b384482346d1ccf11ef53 (patch) | |
tree | 0b0900e26d868b1c3c42e4e3572ff35c84f7f181 /tests/HwAccelerationTest | |
parent | e53c1a1b6bb37e9356121d5d3a6e979c125432ff (diff) |
Add API to set tonal shadow color
Bug: 68211332
Test: HwAccelerationTests's coloredshadow demo & CTS test in topic
Change-Id: I09f5d1067b3200564a9d47219f70985edf3a2527
Diffstat (limited to 'tests/HwAccelerationTest')
3 files changed, 34 insertions, 6 deletions
diff --git a/tests/HwAccelerationTest/AndroidManifest.xml b/tests/HwAccelerationTest/AndroidManifest.xml index ebf5f6854c6f..c8f96c9f0670 100644 --- a/tests/HwAccelerationTest/AndroidManifest.xml +++ b/tests/HwAccelerationTest/AndroidManifest.xml @@ -285,7 +285,8 @@ <activity android:name="ColoredShadowsActivity" - android:label="View/ColoredShadows"> + android:label="View/ColoredShadows" + android:theme="@style/ThemeColoredShadows"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="com.android.test.hwui.TEST" /> diff --git a/tests/HwAccelerationTest/res/values/styles.xml b/tests/HwAccelerationTest/res/values/styles.xml index 108709bd76b2..fa5437f38ace 100644 --- a/tests/HwAccelerationTest/res/values/styles.xml +++ b/tests/HwAccelerationTest/res/values/styles.xml @@ -34,4 +34,11 @@ <item name="android:translationZ">400dp</item> <item name="android:layout_alignParentBottom">true</item> </style> + + <style name="ThemeColoredShadows" parent="@android:style/Theme.Material.Light"> + <!-- + <item name="android:ambientShadowAlpha">0</item> + <item name="android:spotShadowAlpha">1</item> + --> + </style> </resources> diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/ColoredShadowsActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/ColoredShadowsActivity.java index 135c93c97af2..901d90eed70a 100644 --- a/tests/HwAccelerationTest/src/com/android/test/hwui/ColoredShadowsActivity.java +++ b/tests/HwAccelerationTest/src/com/android/test/hwui/ColoredShadowsActivity.java @@ -17,6 +17,9 @@ package com.android.test.hwui; import android.app.Activity; +import android.graphics.Color; +import android.graphics.PixelFormat; +import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; @@ -36,7 +39,9 @@ public class ColoredShadowsActivity extends Activity { private void setShadowColors(ViewGroup row, int rowIndex) { for (int i = 0; i < row.getChildCount(); i++) { View view = row.getChildAt(i); - view.setShadowColor(shadowColorFor(view)); + //view.setBackground(new MyHackyBackground()); + view.setOutlineSpotShadowColor(shadowColorFor(view)); + view.setOutlineAmbientShadowColor(shadowColorFor(view)); view.setElevation(6.0f * (rowIndex + 1)); } } @@ -44,12 +49,27 @@ public class ColoredShadowsActivity extends Activity { private int shadowColorFor(View view) { switch (view.getId()) { case R.id.grey: return 0xFF3C4043; - case R.id.blue: return 0xFF185ABC; - case R.id.red: return 0xFFB31412; - case R.id.yellow: return 0xFFEA8600; - case R.id.green: return 0xFF137333; + case R.id.blue: return Color.BLUE; + case R.id.red: return 0xFFEA4335; + case R.id.yellow: return 0xFFFBBC04; + case R.id.green: return 0xFF34A853; default: return 0xFF000000; } } + private static class MyHackyBackground extends ColorDrawable { + MyHackyBackground() { + super(0); + } + + @Override + public int getOpacity() { + return PixelFormat.TRANSLUCENT; + } + + @Override + public int getAlpha() { + return 254; + } + } } |