# MaskableFrameLayout

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/carousel/MaskableFrameLayout.java)

*** ** * ** ***


```
public class MaskableFrameLayout implements Shapeable
```

<br />

*** ** * ** ***

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

## Summary

| ### Public fields |
|---|---|
| `float` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#maskXPercentage()` |
| `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#shapeAppearanceModel()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#MaskableFrameLayout(Context)(Context context)` |
| `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#MaskableFrameLayout(Context,AttributeSet)(Context context, AttributeSet attrs)` |
| `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#MaskableFrameLayout(Context,AttributeSet,int)( Context context, AttributeSet attrs, int defStyleAttr )` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#getFocusedRect(Rect)(Rect r)` |
| `RectF` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#getMaskRectF()()` Gets a RectF that this View is masked itself by. |
| `float` | `[getMaskXPercentage](https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#getMaskXPercentage())()` **This method is deprecated.** This is no longer used as `https://developer.android.com/reference/com/google/android/material/carousel/CarouselLayoutManager` calculates its own mask percentages. <br /> |
| `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#getShapeAppearanceModel()()` Returns the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` used for the shape definition. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#onHoverEvent(MotionEvent)(MotionEvent event)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo)(AccessibilityNodeInfo info)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#onInterceptTouchEvent(MotionEvent)(MotionEvent event)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#onTouchEvent(MotionEvent)(MotionEvent event)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#setMaskRectF(RectF)(RectF maskRect)` Sets the RectF that this View will be masked by. |
| `abstract void` | `[setMaskXPercentage](https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#setMaskXPercentage(float))(float percentage)` **This method is deprecated.** `https://developer.android.com/reference/com/google/android/material/carousel/CarouselLayoutManager` calculates its own mask percentages. <br /> |
| `void` | `[setMaskXPercentage](https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#setMaskXPercentage(float))(float percentage)` **This method is deprecated.** This is no longer used as `https://developer.android.com/reference/com/google/android/material/carousel/CarouselLayoutManager` calculates its own mask percentages. <br /> |
| `void` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#setOnHoverListener(OnHoverListener)(OnHoverListener l)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#setOnMaskChangedListener(com.google.android.material.carousel.OnMaskChangedListener)(https://developer.android.com/reference/com/google/android/material/carousel/OnMaskChangedListener onMaskChangedListener)` Sets an `https://developer.android.com/reference/com/google/android/material/carousel/OnMaskChangedListener`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#setShapeAppearanceModel(com.google.android.material.shape.ShapeAppearanceModel)(https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel shapeAppearanceModel)` Sets the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` that defines the shape. |

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#dispatchDraw(Canvas)(Canvas canvas)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#onAttachedToWindow()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#onDetachedFromWindow()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#onSizeChanged(int,int,int,int)(int w, int h, int oldw, int oldh)` |

## Public fields

### maskXPercentage

```
public float maskXPercentage
```

### shapeAppearanceModel

```
public ShapeAppearanceModel shapeAppearanceModel
```

## Public constructors

### MaskableFrameLayout

```
public MaskableFrameLayout(Context context)
```

### MaskableFrameLayout

```
public MaskableFrameLayout(Context context, AttributeSet attrs)
```

### MaskableFrameLayout

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

## Public methods

### getFocusedRect

```
public void getFocusedRect(Rect r)
```

### getMaskRectF

```
public RectF getMaskRectF()
```

Gets a RectF that this View is masked itself by.

### getMaskXPercentage

```
public float [getMaskXPercentage](https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#getMaskXPercentage())()
```

> [!CAUTION]
> **This method is deprecated.**   
>
> This is no longer used as `https://developer.android.com/reference/com/google/android/material/carousel/CarouselLayoutManager` calculates its own mask percentages.

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 `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` used for the shape definition.

This `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` can be modified to change the shape.

### onHoverEvent

```
public boolean onHoverEvent(MotionEvent event)
```

### onInitializeAccessibilityNodeInfo

```
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)
```

### onInterceptTouchEvent

```
public boolean onInterceptTouchEvent(MotionEvent event)
```

### onTouchEvent

```
public boolean onTouchEvent(MotionEvent event)
```

### setMaskRectF

```
public void setMaskRectF(RectF maskRect)
```

Sets the RectF that this View will be masked by.

| Parameters |
|---|---|
| `RectF maskRect` | a rect in the view's coordinates to mask by |

### setMaskXPercentage

```
public abstract void [setMaskXPercentage](https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#setMaskXPercentage(float))(float percentage)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> `https://developer.android.com/reference/com/google/android/material/carousel/CarouselLayoutManager` calculates its own mask percentages.

Set the percentage by which this View should mask itself along the x axis.

This method serves the same purpose as `https://developer.android.com/reference/com/google/android/material/carousel/Maskable#setMaskRectF(RectF)` but requires the implementing view to calculate the correct rect given the mask percentage.

| Parameters |
|---|---|
| `float percentage` | 0 when this view is fully unmasked. 1 when this view is fully masked. |

### setMaskXPercentage

```
public void [setMaskXPercentage](https://developer.android.com/reference/com/google/android/material/carousel/MaskableFrameLayout#setMaskXPercentage(float))(float percentage)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> This is no longer used as `https://developer.android.com/reference/com/google/android/material/carousel/CarouselLayoutManager` calculates its own mask percentages.

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

| Parameters |
|---|---|
| `float percentage` | 0 when this view is fully unmasked. 1 when this view is fully masked. |

### setOnHoverListener

```
public void setOnHoverListener(OnHoverListener l)
```

### setOnMaskChangedListener

```
public void setOnMaskChangedListener(OnMaskChangedListener onMaskChangedListener)
```

Sets an `https://developer.android.com/reference/com/google/android/material/carousel/OnMaskChangedListener`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/com/google/android/material/carousel/OnMaskChangedListener onMaskChangedListener` | a listener to receive callbacks for changes in the mask or null to clear the listener. |

### setShapeAppearanceModel

```
public void setShapeAppearanceModel(ShapeAppearanceModel shapeAppearanceModel)
```

Sets the `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearanceModel` that defines the shape.

## Protected methods

### dispatchDraw

```
protected void dispatchDraw(Canvas canvas)
```

### onAttachedToWindow

```
protected void onAttachedToWindow()
```

### onDetachedFromWindow

```
protected void onDetachedFromWindow()
```

### onSizeChanged

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