# ShapeDrawable.ShaderFactory

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# ShaderFactory

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/graphics/drawable/ShapeDrawable.ShaderFactory "View this page in Java")  

```
abstract class ShaderFactory
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                                 ||
| ↳ | [android.graphics.drawable.ShapeDrawable.ShaderFactory](https://developer.android.com/reference/kotlin/android/graphics/drawable/ShapeDrawable.ShaderFactory#) |

Base class defines a factory object that is called each time the drawable is resized (has a new width or height). Its resize() method returns a corresponding shader, or null. Implement this class if you'd like your ShapeDrawable to use a special[android.graphics.Shader](https://developer.android.com/reference/kotlin/android/graphics/Shader.html#), such as a[android.graphics.LinearGradient](https://developer.android.com/reference/kotlin/android/graphics/LinearGradient.html#).

## Summary

|                                                                 Public constructors                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [ShaderFactory](https://developer.android.com/reference/kotlin/android/graphics/drawable/ShapeDrawable.ShaderFactory#ShaderFactory())`()` <br /> |

|                                                                                                                                                                                                                                       Public methods                                                                                                                                                                                                                                       ||
|-------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstract[Shader](https://developer.android.com/reference/kotlin/android/graphics/Shader.html#)! | [resize](https://developer.android.com/reference/kotlin/android/graphics/drawable/ShapeDrawable.ShaderFactory#resize(kotlin.Int,%20kotlin.Int))`(`width:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `height:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Returns the Shader to be drawn when a Drawable is drawn. |

## Public constructors

### ShaderFactory

```
ShaderFactory()
```

## Public methods

### resize

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
abstract fun resize(
    width: Int, 
    height: Int
): Shader!
```

Returns the Shader to be drawn when a Drawable is drawn. The dimensions of the Drawable are passed because they may be needed to adjust how the Shader is configured for drawing. This is called by ShapeDrawable.setShape().

|                                                         Parameters                                                         ||
|----------|------------------------------------------------------------------------------------------------------------------|
| `width`  | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the width of the Drawable being drawn |
| `height` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the heigh of the Drawable being drawn |

|                                                     Return                                                      ||
|-----------------------------------------------------------------------------------------|------------------------|
| [Shader](https://developer.android.com/reference/kotlin/android/graphics/Shader.html#)! | the Shader to be drawn |