MaskableFrameLayout

public class MaskableFrameLayout
extends FrameLayout implements Shapeable

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ com.google.android.material.carousel.MaskableFrameLayout


A FrameLayout than is able to mask itself and all children.

Summary

Inherited constants

Inherited fields

Public constructors

MaskableFrameLayout(Context context)
MaskableFrameLayout(Context context, AttributeSet attrs)
MaskableFrameLayout(Context context, AttributeSet attrs, int defStyleAttr)

Public methods

RectF getMaskRectF()

Gets a RectF that this View is masked itself by.

float getMaskXPercentage()

Gets the percentage by which this View is masked by along the x axis.

ShapeAppearanceModel getShapeAppearanceModel()

Returns the ShapeAppearanceModel used for the shape definition.

boolean onTouchEvent(MotionEvent event)
void setMaskXPercentage(float percentage)

Sets the percentage by which this View masks by along the x axis.

void setOnMaskChangedListener(OnMaskChangedListener onMaskChangedListener)
void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel)

Sets the ShapeAppearanceModel that defines the shape.

Protected methods

void dispatchDraw(Canvas canvas)
void onAttachedToWindow()
void onDetachedFromWindow()
void onSizeChanged(int w, int h, int oldw, int oldh)

Inherited methods

Public constructors

MaskableFrameLayout

public MaskableFrameLayout (Context context)

Parameters
context Context

MaskableFrameLayout

public MaskableFrameLayout (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

MaskableFrameLayout

public MaskableFrameLayout (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

getMaskRectF

public RectF getMaskRectF ()

Gets a RectF that this View is masked itself by.

Returns
RectF

getMaskXPercentage

public float getMaskXPercentage ()

Gets the percentage by which this View is masked by along the x axis.

Returns
float a float between 0 and 1 where 0 is fully unmasked and 1 is fully masked.

getShapeAppearanceModel

public ShapeAppearanceModel getShapeAppearanceModel ()

Returns the ShapeAppearanceModel used for the shape definition.

This ShapeAppearanceModel can be modified to change the shape.

Returns
ShapeAppearanceModel

onTouchEvent

public boolean onTouchEvent (MotionEvent event)

Parameters
event MotionEvent

Returns
boolean

setMaskXPercentage

public void setMaskXPercentage (float percentage)

Sets the percentage by which this View masks by along the x axis.

Parameters
percentage float: 0 when this view is fully unmasked. 1 when this view is fully masked.

setOnMaskChangedListener

public void setOnMaskChangedListener (OnMaskChangedListener onMaskChangedListener)

Parameters
onMaskChangedListener OnMaskChangedListener

setShapeAppearanceModel

public void setShapeAppearanceModel (ShapeAppearanceModel shapeAppearanceModel)

Sets the ShapeAppearanceModel that defines the shape.

Parameters
shapeAppearanceModel ShapeAppearanceModel

Protected methods

dispatchDraw

protected void dispatchDraw (Canvas canvas)

Parameters
canvas Canvas

onAttachedToWindow

protected void onAttachedToWindow ()

onDetachedFromWindow

protected void onDetachedFromWindow ()

onSizeChanged

protected void onSizeChanged (int w, 
                int h, 
                int oldw, 
                int oldh)

Parameters
w int

h int

oldw int

oldh int