Language

ShapeDrawable.Opacity Property

Definition

Return the opacity/transparency of this Drawable.

public override int Opacity { [Android.Runtime.Register("getOpacity", "()I", "GetGetOpacityHandler")] get; }
[<get: Android.Runtime.Register("getOpacity", "()I", "GetGetOpacityHandler")>]
member this.Opacity : int

Property Value

int The opacity class of the Drawable. Value is one of the following: PixelFormat.UNKNOWN; PixelFormat.TRANSLUCENT; PixelFormat.TRANSPARENT; PixelFormat.OPAQUE

Attributes

Remarks

This method is deprecated. This method is no longer used in graphics optimizations

Return the opacity/transparency of this Drawable. The returned value is one of the abstract format constants in PixelFormat: PixelFormat.UNKNOWN, PixelFormat.TRANSLUCENT, PixelFormat.TRANSPARENT, or PixelFormat.OPAQUE.

An OPAQUE drawable is one that draws all all content within its bounds, completely covering anything behind the drawable. A TRANSPARENT drawable is one that draws nothing within its bounds, allowing everything behind it to show through. A TRANSLUCENT drawable is a drawable in any other state, where the drawable will draw some, but not all, of the content within its bounds and at least some content behind the drawable will be visible. If the visibility of the drawable's contents cannot be determined, the safest/best return value is TRANSLUCENT.

Generally a Drawable should be as conservative as possible with the value it returns. For example, if it contains multiple child drawables and only shows one of them at a time, if only one of the children is TRANSLUCENT and the others are OPAQUE then TRANSLUCENT should be returned. You can use the method resolveOpacity(int, int) to perform a standard reduction of two opacities to the appropriate single output.

Note that the returned value does not necessarily take into account a custom alpha or color filter that has been applied by the client through the setAlpha(int) or setColorFilter(ColorFilter) methods. Some subclasses, such as BitmapDrawable, ColorDrawable, and GradientDrawable, do account for the value of setAlpha(int), but the general behavior is dependent upon the implementation of the subclass.

Android reference for android.graphics.drawable.ShapeDrawable.getOpacity.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to