Stay organized with collections
Save and categorize content based on your preferences.
OvalShape
open class OvalShape : RectShape
Defines an oval shape.
The oval can be drawn to a Canvas with its own draw() method, but more graphical control is available if you instead pass the OvalShape to a android.graphics.drawable.ShapeDrawable
.
Summary
Public constructors
Public methods
clone
open fun clone(): OvalShape
Exceptions |
java.lang.CloneNotSupportedException |
if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned. |
draw
open fun draw(
canvas: Canvas!,
paint: Paint!
): Unit
Parameters |
canvas |
Canvas!: the Canvas within which this shape should be drawn |
paint |
Paint!: the Paint object that defines this shape's characteristics |
getOutline
open fun getOutline(outline: Outline): Unit
Parameters |
outline |
Outline: the Outline to be populated with the result. Must be non-null . |
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,["# OvalShape\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOvalShape\n=========\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/graphics/drawable/shapes/OvalShape \"View this page in Java\") \n\n```\nopen class OvalShape : RectShape\n```\n\n|---|---|---|-------------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||||\n| ↳ | [android.graphics.drawable.shapes.Shape](/reference/kotlin/android/graphics/drawable/shapes/Shape) |||\n| | ↳ | [android.graphics.drawable.shapes.RectShape](/reference/kotlin/android/graphics/drawable/shapes/RectShape) ||\n| | | ↳ | [android.graphics.drawable.shapes.OvalShape](#) |\n\nDefines an oval shape.\n\nThe oval can be drawn to a Canvas with its own draw() method, but more graphical control is available if you instead pass the OvalShape to a [android.graphics.drawable.ShapeDrawable](../ShapeDrawable.html#).\n\nSummary\n-------\n\n| Public constructors ||\n|--------------------------------------|---|\n| [OvalShape](#OvalShape())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [OvalShape](#) | [clone](#clone())`()` \u003cbr /\u003e |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [draw](#draw(android.graphics.Canvas,%20android.graphics.Paint))`(`canvas:` `[Canvas](../../Canvas.html#)!`, `paint:` `[Paint](../../Paint.html#)!`)` \u003cbr /\u003e |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [getOutline](#getOutline(android.graphics.Outline))`(`outline:` `[Outline](../../Outline.html#)`)` \u003cbr /\u003e |\n\n| Inherited functions ||\n|---|---|\n| From class [RectShape](/reference/kotlin/android/graphics/drawable/shapes/RectShape) |------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [equals](/reference/kotlin/android/graphics/drawable/shapes/RectShape#equals(kotlin.Any))`(`other:` `[Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)?`)` \u003cbr /\u003e | | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [hashCode](/reference/kotlin/android/graphics/drawable/shapes/RectShape#hashCode())`()` \u003cbr /\u003e | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onResize](/reference/kotlin/android/graphics/drawable/shapes/RectShape#onResize(kotlin.Float,%20kotlin.Float))`(`width:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `height:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` \u003cbr /\u003e | | [RectF](../../RectF.html#)! | [rect](/reference/kotlin/android/graphics/drawable/shapes/RectShape#rect())`()` Returns the RectF that defines this rectangle's bounds. \u003cbr /\u003e | ||\n| From class [Shape](/reference/kotlin/android/graphics/drawable/shapes/Shape) |------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html) | [getHeight](/reference/kotlin/android/graphics/drawable/shapes/Shape#getHeight())`()` Returns the height of the Shape. \u003cbr /\u003e | | [Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html) | [getWidth](/reference/kotlin/android/graphics/drawable/shapes/Shape#getWidth())`()` Returns the width of the Shape. \u003cbr /\u003e | | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [hasAlpha](/reference/kotlin/android/graphics/drawable/shapes/Shape#hasAlpha())`()` Checks whether the Shape is opaque. Default impl returns `true`. Override if your subclass can be opaque. \u003cbr /\u003e | | [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [resize](/reference/kotlin/android/graphics/drawable/shapes/Shape#resize(kotlin.Float,%20kotlin.Float))`(`width:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`, `height:` `[Float](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-float/index.html)`)` Resizes the dimensions of this shape. Must be called before [draw(android.graphics.Canvas,android.graphics.Paint)](/reference/kotlin/android/graphics/drawable/shapes/Shape#draw(android.graphics.Canvas,%20android.graphics.Paint)). \u003cbr /\u003e | ||\n\nPublic constructors\n-------------------\n\n### OvalShape\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nOvalShape()\n```\n\nPublic methods\n--------------\n\n### clone\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun clone(): OvalShape\n```\n\n| Return ||\n|----------------|---------------------------|\n| [OvalShape](#) | a clone of this instance. |\n\n| Exceptions ||\n|----------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `java.lang.CloneNotSupportedException` | if the object's class does not support the `Cloneable` interface. Subclasses that override the `clone` method can also throw this exception to indicate that an instance cannot be cloned. |\n\n### draw\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun draw(\n canvas: Canvas!, \n paint: Paint!\n): Unit\n```\n\n| Parameters ||\n|----------|-----------------------------------------------------------------------------------------|\n| `canvas` | [Canvas](../../Canvas.html#)!: the Canvas within which this shape should be drawn |\n| `paint` | [Paint](../../Paint.html#)!: the Paint object that defines this shape's characteristics |\n\n### getOutline\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getOutline(outline: Outline): Unit\n```\n\n| Parameters ||\n|-----------|--------------------------------------------------------------------------------------------------|\n| `outline` | [Outline](../../Outline.html#): the Outline to be populated with the result. Must be non-`null`. |"]]