summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/current.txt3
-rw-r--r--core/java/android/view/View.java34
-rw-r--r--core/java/android/view/ViewOutlineProvider.java29
-rw-r--r--core/res/res/values/attrs.xml13
-rw-r--r--core/res/res/values/public.xml1
5 files changed, 72 insertions, 8 deletions
diff --git a/api/current.txt b/api/current.txt
index b2106d2..3faf5b9 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -930,6 +930,7 @@ package android {
field public static final int orderingFromXml = 16843239; // 0x10101e7
field public static final int orientation = 16842948; // 0x10100c4
field public static final int outAnimation = 16843128; // 0x1010178
+ field public static final int outlineProvider = 16843961; // 0x10104b9
field public static final int overScrollFooter = 16843459; // 0x10102c3
field public static final int overScrollHeader = 16843458; // 0x10102c2
field public static final int overScrollMode = 16843457; // 0x10102c1
@@ -35193,6 +35194,8 @@ package android.view {
ctor public ViewOutlineProvider();
method public abstract void getOutline(android.view.View, android.graphics.Outline);
field public static final android.view.ViewOutlineProvider BACKGROUND;
+ field public static final android.view.ViewOutlineProvider BOUNDS;
+ field public static final android.view.ViewOutlineProvider PADDED_BOUNDS;
}
public class ViewOverlay {
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 3adc41a..f17daaf 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -4047,6 +4047,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
mBackgroundTintMode = Drawable.parseTintMode(a.getInt(
R.styleable.View_backgroundTintMode, -1), mBackgroundTintMode);
break;
+ case R.styleable.View_outlineProvider:
+ setOutlineProviderFromAttribute(a.getInt(R.styleable.View_outlineProvider,
+ PROVIDER_BACKGROUND));
+ break;
}
}
@@ -10824,14 +10828,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
/**
- * Deprecated, pending removal
- *
- * @hide
- */
- @Deprecated
- public void setOutline(@Nullable Outline outline) {}
-
- /**
* Returns whether the Outline should be used to clip the contents of the View.
* <p>
* Note that this flag will only be respected if the View's Outline returns true from
@@ -10860,6 +10856,28 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
}
+ // correspond to the enum values of View_outlineProvider
+ private static final int PROVIDER_BACKGROUND = 0;
+ private static final int PROVIDER_NONE = 1;
+ private static final int PROVIDER_BOUNDS = 2;
+ private static final int PROVIDER_PADDED_BOUNDS = 3;
+ private void setOutlineProviderFromAttribute(int providerInt) {
+ switch (providerInt) {
+ case PROVIDER_BACKGROUND:
+ setOutlineProvider(ViewOutlineProvider.BACKGROUND);
+ break;
+ case PROVIDER_NONE:
+ setOutlineProvider(null);
+ break;
+ case PROVIDER_BOUNDS:
+ setOutlineProvider(ViewOutlineProvider.BOUNDS);
+ break;
+ case PROVIDER_PADDED_BOUNDS:
+ setOutlineProvider(ViewOutlineProvider.PADDED_BOUNDS);
+ break;
+ }
+ }
+
/**
* Sets the {@link ViewOutlineProvider} of the view, which generates the Outline that defines
* the shape of the shadow it casts, and enables outline clipping.
diff --git a/core/java/android/view/ViewOutlineProvider.java b/core/java/android/view/ViewOutlineProvider.java
index 170c5d8..a1a02f6 100644
--- a/core/java/android/view/ViewOutlineProvider.java
+++ b/core/java/android/view/ViewOutlineProvider.java
@@ -44,6 +44,35 @@ public abstract class ViewOutlineProvider {
};
/**
+ * Maintains the outline of the View to match its rectangular bounds,
+ * at <code>1.0f</code> alpha.
+ *
+ * This can be used to enable Views that are opaque but lacking a background cast a shadow.
+ */
+ public static final ViewOutlineProvider BOUNDS = new ViewOutlineProvider() {
+ @Override
+ public void getOutline(View view, Outline outline) {
+ outline.setRect(0, 0, view.getWidth(), view.getHeight());
+ }
+ };
+
+ /**
+ * Maintains the outline of the View to match its rectangular padded bounds,
+ * at <code>1.0f</code> alpha.
+ *
+ * This can be used to enable Views that are opaque but lacking a background cast a shadow.
+ */
+ public static final ViewOutlineProvider PADDED_BOUNDS = new ViewOutlineProvider() {
+ @Override
+ public void getOutline(View view, Outline outline) {
+ outline.setRect(view.getPaddingLeft(),
+ view.getPaddingTop(),
+ view.getWidth() - view.getPaddingRight(),
+ view.getHeight() - view.getPaddingBottom());
+ }
+ };
+
+ /**
* Called to get the provider to populate the Outline.
*
* This method will be called by a View when its owned Drawables are invalidated, when the
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index f9ea5d8..08aaa6a 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -2513,6 +2513,19 @@
result to valid color values. Saturate(S + D) -->
<enum name="add" value="16" />
</attr>
+
+ <!-- ViewOutlineProvider used to determine the View's Outline. -->
+ <attr name="outlineProvider">
+ <!-- Default, background drawable-driven outline. -->
+ <enum name="background" value="0" />
+ <!-- No outline provider. -->
+ <enum name="none" value="1" />
+ <!-- Generates an opaque outline for the bounds of the view. -->
+ <enum name="bounds" value="2" />
+ <!-- Generates an opaque outline for the padded bounds of the view. -->
+ <enum name="paddedBounds" value="3" />
+ </attr>
+
</declare-styleable>
<!-- Attributes that can be assigned to a tag for a particular View. -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 7ade51d..ed66c65 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2272,6 +2272,7 @@
<public type="attr" name="inset" />
<public type="attr" name="letterSpacing" />
<public type="attr" name="fontFeatureSettings" />
+ <public type="attr" name="outlineProvider" />
<public-padding type="dimen" name="l_resource_pad" end="0x01050010" />