public class

MaskedLayout

extends FrameLayout
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ com.droidux.ui.widgets.layout.MaskedLayout

Class Overview

Given a drawable to be used as a mask, this layout will draw it's children masked by the drawable. This might be useful if you need an irregularly shaped layout.

Summary

XML Attributes
Attribute Name Related Method Description
duxlyt_enableMask setEnableMask(boolean) Whether the view should be masked. 
duxlyt_maskDrawable setMaskDrawable(int) Set the drawable that should be used as the mask. 
duxlyt_maskMode Specify the way the mask should be applied when drawing the view. 
duxlyt_overDrawable setOverlayDrawable(Drawable) Set the drawable that should be used as an overlay. 
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
MaskedLayout(Context context)
MaskedLayout(Context context, AttributeSet attrs)
MaskedLayout(Context context, AttributeSet attrs, int defStyle)
Public Methods
boolean getEnableMask()
Whether the view should be masked by the given mask drawable.
Drawable getMaskDrawable()
Retrieve the mask drawable, or null if no drawable has been set as a mask.
Drawable getOverlayDrawable()
Retrieve the overlay drawable, or null if no drawable has been set as a mask.
void setEnableMask(boolean enable)
When enabled and the getMaskDrawable() is not null, the view masked by the given mask drawable.
void setMaskDrawable(Drawable mask)
Sets the mask drawable.
void setMaskDrawable(int mask)
Sets the mask drawable.
void setOverlayDrawable(int overlay)
Sets the overlay drawable.
void setOverlayDrawable(Drawable overlay)
Sets the overlay drawable.
[Expand]
Inherited Methods
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

XML Attributes

duxlyt_enableMask

Since: API Level

Whether the view should be masked. Default is true.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

Related Methods

duxlyt_maskDrawable

Since: API Level

Set the drawable that should be used as the mask. By default, the mask drawable is a circle/oval shape drawable.

Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".

Related Methods

duxlyt_maskMode

Since: API Level

Specify the way the mask should be applied when drawing the view.

Must be one of the following constant values.

ConstantValueDescription
all0 Mask the whole view, including the background
content1 Mask only the content, excluding the background

Related Methods

duxlyt_overDrawable

Since: API Level

Set the drawable that should be used as an overlay. The overlay will be drawn on top of the image.

Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".

Public Constructors

public MaskedLayout (Context context)

Since: API Level 3.0

public MaskedLayout (Context context, AttributeSet attrs)

Since: API Level 3.0

public MaskedLayout (Context context, AttributeSet attrs, int defStyle)

Since: API Level 3.0

Public Methods

public boolean getEnableMask ()

Since: API Level 3.0

Whether the view should be masked by the given mask drawable.

Related XML Attributes
Returns
  • true if the view should be masked.

public Drawable getMaskDrawable ()

Since: API Level 3.0

Retrieve the mask drawable, or null if no drawable has been set as a mask.

Related XML Attributes
Returns
  • The mask drawable or null if none is set.

public Drawable getOverlayDrawable ()

Since: API Level 3.0

Retrieve the overlay drawable, or null if no drawable has been set as a mask.

Related XML Attributes
Returns
  • The overlay drawable or null if none is set.

public void setEnableMask (boolean enable)

Since: API Level 3.0

When enabled and the getMaskDrawable() is not null, the view masked by the given mask drawable. By default, it's enabled.

Related XML Attributes
Parameters
enable If true the view will be masked by the mask drawable. Otherwise, the view will be drawn normally.

public void setMaskDrawable (Drawable mask)

Since: API Level 3.0

Sets the mask drawable.

Related XML Attributes
Parameters
mask The drawable used to mask the layout.

public void setMaskDrawable (int mask)

Since: API Level 3.0

Sets the mask drawable.

Related XML Attributes
Parameters
mask The drawable resource used to mask the layout.

public void setOverlayDrawable (int overlay)

Since: API Level 3.0

Sets the overlay drawable.

Related XML Attributes
Parameters
overlay The drawable resource used to mask the layout.

public void setOverlayDrawable (Drawable overlay)

Since: API Level 3.0

Sets the overlay drawable.

Related XML Attributes
Parameters
overlay The drawable used to mask the layout.