Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f873d86 authored by Chris Craik's avatar Chris Craik
Browse files

Implement alpha as documented for drawables

bug:17693526

With this change, outline opacity isn't published by default, as was
intended. Default behavior for custom drawables is to have a
rectangular outline, but not cast a shadow, e.g. as a button
background.

Change-Id: If80a256ff359bcb58f3f593ec9018f2df5fc4e44
parent 9eef5bf8
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.graphics.drawable;

import android.annotation.NonNull;
import android.graphics.*;
import android.graphics.PorterDuff.Mode;
import android.content.res.ColorStateList;
@@ -210,6 +211,12 @@ public class ColorDrawable extends Drawable {
        return PixelFormat.TRANSLUCENT;
    }

    @Override
    public void getOutline(@NonNull Outline outline) {
        outline.setRect(getBounds());
        outline.setAlpha(getAlpha() / 255.0f);
    }

    @Override
    public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Theme theme)
            throws XmlPullParserException, IOException {
+1 −1
Original line number Diff line number Diff line
@@ -895,7 +895,7 @@ public abstract class Drawable {
     */
    public void getOutline(@NonNull Outline outline) {
        outline.setRect(getBounds());
        outline.setAlpha(getAlpha() / 255.0f);
        outline.setAlpha(0);
    }

    /**