summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris Craik <ccraik@google.com>2014-07-18 13:55:26 -0700
committerChris Craik <ccraik@google.com>2014-07-18 15:54:40 -0700
commitca4d5ef5f5b200623869ec3b08d2cf518851eb4e (patch)
tree756843d5f0a39a6cbc51eeedb9e0806cc17c9d1f /src
parent86cd19e3a1fded3a43cad1e3206ba7c0878aaaa5 (diff)
downloadandroid_packages_apps_PhoneCommon-ca4d5ef5f5b200623869ec3b08d2cf518851eb4e.tar.gz
android_packages_apps_PhoneCommon-ca4d5ef5f5b200623869ec3b08d2cf518851eb4e.tar.bz2
android_packages_apps_PhoneCommon-ca4d5ef5f5b200623869ec3b08d2cf518851eb4e.zip
Update Outline API
Change-Id: Iab76b6e4f0a384e3b633d2c1050dbf353cc1bcd2
Diffstat (limited to 'src')
-rw-r--r--src/com/android/phone/common/util/ViewUtil.java24
1 files changed, 9 insertions, 15 deletions
diff --git a/src/com/android/phone/common/util/ViewUtil.java b/src/com/android/phone/common/util/ViewUtil.java
index 34b6274..6611c3b 100644
--- a/src/com/android/phone/common/util/ViewUtil.java
+++ b/src/com/android/phone/common/util/ViewUtil.java
@@ -22,6 +22,7 @@ import android.graphics.Paint;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewOutlineProvider;
import android.widget.ListView;
import android.widget.TextView;
@@ -58,27 +59,20 @@ public class ViewUtil {
return view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}
+ private static final ViewOutlineProvider OVAL_OUTLINE_PROVIDER = new ViewOutlineProvider() {
+ @Override
+ public void getOutline(View view, Outline outline) {
+ outline.setOval(0, 0, view.getWidth(), view.getHeight());
+ }
+ };
+
/**
* Configures the floating action button, clipping it to a circle and setting its translation z.
* @param view The float action button's view.
* @param res The resources file.
*/
public static void setupFloatingActionButton(View view, Resources res) {
- // Once layout is complete and the floating action button has been assigned a width and
- // height, assign the outline.
- view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
- @Override
- public void onLayoutChange(View v, int left, int top, int right, int bottom,
- int oldLeft, int oldTop, int oldRight, int oldBottom) {
- final Outline outline = new Outline();
- final int minDimension = Math.min(right - left, bottom - top);
- if (minDimension <= 0) {
- return;
- }
- outline.setRoundRect(0, 0, right - left, bottom - top, minDimension / 2);
- v.setOutline(outline);
- }
- });
+ view.setOutlineProvider(OVAL_OUTLINE_PROVIDER);
view.setTranslationZ(
res.getDimensionPixelSize(R.dimen.floating_action_button_translation_z));
}