# FocusRingDrawable

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

*** ** * ** ***


```
public class FocusRingDrawable
```

<br />

*** ** * ** ***

Drawable wrapper that provides focus rings.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#FocusRingDrawable()()` |
| `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#FocusRingDrawable(Context,Drawable)(Context context, Drawable drawable)` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#applyTheme(Theme)(Theme theme)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#canApplyTheme()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#draw(Canvas)(Canvas canvas)` |
| `static https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#find(Drawable)(Drawable drawable)` Search for and return a FocusRingDrawable if it is either the provided drawable or one level deep in a DrawableWrapper or LayerDrawable. |
| `static https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#findAndMutate(Drawable)(Drawable drawable)` Search for, mutate, and return a FocusRingDrawable if it is either the provided drawable or one level deep in a DrawableWrapper or LayerDrawable. |
| `ConstantState` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#getConstantState()()` |
| `Rect` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#getFocusRingBounds()()` |
| `float` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#getFocusRingInnerInset()()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#getFocusRingInnerStrokeColor()()` |
| `float` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#getFocusRingInnerStrokeWidth()()` |
| `float` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#getFocusRingInset()()` |
| `https://developer.android.com/reference/com/google/android/material/shape/MaterialShapeDrawable` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#getFocusRingMaterialShapeDrawable()()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#getFocusRingOuterStrokeColor()()` |
| `float` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#getFocusRingOuterStrokeWidth()()` |
| `float` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#getFocusRingRadius()()` |
| `https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearance` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#getFocusRingShapeAppearance()()` |
| `int[]` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#getFocusRingStateSet()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#hasFocusStateSpecified()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#inflate(Resources,XmlPullParser,AttributeSet)(Resources res, XmlPullParser parser, AttributeSet attrs)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#inflate(Resources,XmlPullParser,AttributeSet,Theme)( Resources res, XmlPullParser parser, AttributeSet attrs, Theme theme )` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#isFocusRingEnabled()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#isProjected()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#isStateful()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#jumpToCurrentState()()` |
| `static https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#layer(Context,LayerDrawable)(Context context, LayerDrawable layerDrawable)` Add a FocusRingDrawable as a layer to the provided LayerDrawable if focus rings are enabled, otherwise do nothing and return null. |
| `static https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#layer(Context,LayerDrawable,com.google.android.material.shape.MaterialShapeDrawable)( Context context, LayerDrawable layerDrawable, https://developer.android.com/reference/com/google/android/material/shape/MaterialShapeDrawable materialShapeDrawable )` Add a FocusRingDrawable as a layer to the provided LayerDrawable if focus rings are enabled, otherwise do nothing and return null. |
| `Drawable` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#mutate()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingBounds(Rect)(Rect bounds)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingBounds(int,int,int,int)(int left, int top, int right, int bottom)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingEnabled(boolean)(boolean enabled)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingInnerInset(float)(float innerInset)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingInnerStrokeColor(int)(int innerStrokeColor)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingInnerStrokeWidth(float)(float innerStrokeWidth)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingInset(float)(float inset)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingMaterialShapeDrawable(com.google.android.material.shape.MaterialShapeDrawable)( https://developer.android.com/reference/com/google/android/material/shape/MaterialShapeDrawable materialShapeDrawable )` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingOuterStrokeColor(int)(int outerStrokeColor)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingOuterStrokeWidth(float)(float outerStrokeWidth)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingRadius(float)(float radius)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingShapeAppearance(com.google.android.material.shape.ShapeAppearance)(https://developer.android.com/reference/com/google/android/material/shape/ShapeAppearance shapeAppearance)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#setFocusRingStateSet(int[])(int[] stateSet)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#updateFocusRingShapeAppearanceFromWrappedDrawable()()` |
| `static Drawable` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#wrap(Context,Drawable)(Context context, Drawable drawable)` Wrap the provided drawable with a FocusRingDrawable if focus rings are enabled, otherwise just return the provided drawable. |

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#onBoundsChange(Rect)(Rect bounds)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#onStateChange(int[])(int[] stateSet)` |

## Public constructors

### FocusRingDrawable

```
public FocusRingDrawable()
```

### FocusRingDrawable

```
public FocusRingDrawable(Context context, Drawable drawable)
```

## Public methods

### applyTheme

```
public void applyTheme(Theme theme)
```

### canApplyTheme

```
public boolean canApplyTheme()
```

### draw

```
public void draw(Canvas canvas)
```

### find

```
public static FocusRingDrawable find(Drawable drawable)
```

Search for and return a FocusRingDrawable if it is either the provided drawable or one level deep in a DrawableWrapper or LayerDrawable.

This is useful for finding a FocusRingDrawable that has been set up with either `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#wrap(Context,Drawable)` or `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#layer(Context,LayerDrawable,com.google.android.material.shape.MaterialShapeDrawable)`, as well as the equivalent XML drawable configurations.

### findAndMutate

```
public static FocusRingDrawable findAndMutate(Drawable drawable)
```

Search for, mutate, and return a FocusRingDrawable if it is either the provided drawable or one level deep in a DrawableWrapper or LayerDrawable.

If the FocusRingDrawable is a child of a DrawableWrapper or LayerDrawable, then the parent DrawableWrapper or LayerDrawable will be mutated instead of the FocusRingDrawable. This will in turn recreate and mutate the child FocusRingDrawable, which helps prevent issues related to constant state.

Also see `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#find(Drawable)`.

### getConstantState

```
public ConstantState getConstantState()
```

### getFocusRingBounds

```
public Rect getFocusRingBounds()
```

### getFocusRingInnerInset

```
public float getFocusRingInnerInset()
```

### getFocusRingInnerStrokeColor

```
public int getFocusRingInnerStrokeColor()
```

### getFocusRingInnerStrokeWidth

```
public float getFocusRingInnerStrokeWidth()
```

### getFocusRingInset

```
public float getFocusRingInset()
```

### getFocusRingMaterialShapeDrawable

```
public MaterialShapeDrawable getFocusRingMaterialShapeDrawable()
```

### getFocusRingOuterStrokeColor

```
public int getFocusRingOuterStrokeColor()
```

### getFocusRingOuterStrokeWidth

```
public float getFocusRingOuterStrokeWidth()
```

### getFocusRingRadius

```
public float getFocusRingRadius()
```

### getFocusRingShapeAppearance

```
public ShapeAppearance getFocusRingShapeAppearance()
```

### getFocusRingStateSet

```
public int[] getFocusRingStateSet()
```

### hasFocusStateSpecified

```
public boolean hasFocusStateSpecified()
```

### inflate

```
public void inflate(Resources res, XmlPullParser parser, AttributeSet attrs)
```

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |

### inflate

```
public void inflate(
    Resources res,
    XmlPullParser parser,
    AttributeSet attrs,
    Theme theme
)
```

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException` |   |

### isFocusRingEnabled

```
public boolean isFocusRingEnabled()
```

### isProjected

```
public boolean isProjected()
```

### isStateful

```
public boolean isStateful()
```

### jumpToCurrentState

```
public void jumpToCurrentState()
```

### layer

```
public static FocusRingDrawable layer(Context context, LayerDrawable layerDrawable)
```

Add a FocusRingDrawable as a layer to the provided LayerDrawable if focus rings are enabled, otherwise do nothing and return null.

See `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#layer(Context,LayerDrawable,com.google.android.material.shape.MaterialShapeDrawable)`.

### layer

```
public static FocusRingDrawable layer(
    Context context,
    LayerDrawable layerDrawable,
    MaterialShapeDrawable materialShapeDrawable
)
```

Add a FocusRingDrawable as a layer to the provided LayerDrawable if focus rings are enabled, otherwise do nothing and return null.

This method of integrating focus rings should be preferred if the drawable is a bounded ripple drawable (has layers), because we can add the focus ring as a layer without affecting the ripple bounds. See `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#wrap(Context,Drawable)` for an alternative method where the focus ring can wrap the provided drawable instead of being added as a layer.

The MaterialShapeDrawable will be used to draw the focus ring outline shape and bounds.

### mutate

```
public Drawable mutate()
```

### setFocusRingBounds

```
public void setFocusRingBounds(Rect bounds)
```

### setFocusRingBounds

```
public void setFocusRingBounds(int left, int top, int right, int bottom)
```

### setFocusRingEnabled

```
public void setFocusRingEnabled(boolean enabled)
```

### setFocusRingInnerInset

```
public void setFocusRingInnerInset(float innerInset)
```

### setFocusRingInnerStrokeColor

```
public void setFocusRingInnerStrokeColor(int innerStrokeColor)
```

### setFocusRingInnerStrokeWidth

```
public void setFocusRingInnerStrokeWidth(float innerStrokeWidth)
```

### setFocusRingInset

```
public void setFocusRingInset(float inset)
```

### setFocusRingMaterialShapeDrawable

```
public void setFocusRingMaterialShapeDrawable(
    MaterialShapeDrawable materialShapeDrawable
)
```

### setFocusRingOuterStrokeColor

```
public void setFocusRingOuterStrokeColor(int outerStrokeColor)
```

### setFocusRingOuterStrokeWidth

```
public void setFocusRingOuterStrokeWidth(float outerStrokeWidth)
```

### setFocusRingRadius

```
public void setFocusRingRadius(float radius)
```

### setFocusRingShapeAppearance

```
public void setFocusRingShapeAppearance(ShapeAppearance shapeAppearance)
```

### setFocusRingStateSet

```
public void setFocusRingStateSet(int[] stateSet)
```

### updateFocusRingShapeAppearanceFromWrappedDrawable

```
public boolean updateFocusRingShapeAppearanceFromWrappedDrawable()
```

### wrap

```
public static Drawable wrap(Context context, Drawable drawable)
```

Wrap the provided drawable with a FocusRingDrawable if focus rings are enabled, otherwise just return the provided drawable.

This method of integrating focus rings should be preferred if the drawable is an unbounded ripple drawable (has no layers), because wrapping the ripple will preserve the unbounded-ness. See `https://developer.android.com/reference/com/google/android/material/focus/FocusRingDrawable#layer(Context,LayerDrawable,com.google.android.material.shape.MaterialShapeDrawable)` for an alternative method where the focus ring can be added as a layer instead of wrapping.

## Protected methods

### onBoundsChange

```
protected void onBoundsChange(Rect bounds)
```

### onStateChange

```
protected boolean onStateChange(int[] stateSet)
```