Stay organized with collections
Save and categorize content based on your preferences.
ShaderFactory
abstract class 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
, such as a android.graphics.LinearGradient
.
Summary
Public methods |
abstract Shader! |
Returns the Shader to be drawn when a Drawable is drawn.
|
Public constructors
ShaderFactory
ShaderFactory()
Public methods
resize
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: the width of the Drawable being drawn |
height |
Int: the heigh of the Drawable being drawn |
Return |
Shader! |
the Shader to be drawn |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# ShapeDrawable.ShaderFactory\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nShaderFactory\n=============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/graphics/drawable/ShapeDrawable.ShaderFactory \"View this page in Java\") \n\n```\nabstract class ShaderFactory\n```\n\n|---|------------------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.graphics.drawable.ShapeDrawable.ShaderFactory](#) |\n\nBase 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](../Shader.html#), such as a [android.graphics.LinearGradient](../LinearGradient.html#).\n\nSummary\n-------\n\n| Public constructors ||\n|----------------------------------------------|---|\n| [ShaderFactory](#ShaderFactory())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Shader](../Shader.html#)! | [resize](#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. |\n\nPublic constructors\n-------------------\n\n### ShaderFactory\n\n```\nShaderFactory()\n```\n\nPublic methods\n--------------\n\n### resize\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun resize(\n width: Int, \n height: Int\n): Shader!\n```\n\nReturns 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().\n\n| Parameters ||\n|----------|-------------------------------------------------------------------------------------------------------------------|\n| `width` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the width of the Drawable being drawn |\n| `height` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the heigh of the Drawable being drawn |\n\n| Return ||\n|----------------------------|------------------------|\n| [Shader](../Shader.html#)! | the Shader to be drawn |"]]