{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

Stroke

public final class Stroke extends DrawStyle

java.lang.Object
   ↳ androidx.compose.ui.graphics.drawscope.DrawStyle
     ↳ androidx.compose.ui.graphics.drawscope.Stroke

DrawStyle that provides information for drawing content with a stroke

Summary

Nested types

public static class Stroke.Companion

Constants

static final float

Default miter length used in combination with joins

static final float

Width to indicate a hairline stroke of 1 pixel

Public constructors

Stroke(
    float width,
    float miter,
    @NonNull StrokeCap cap,
    @NonNull StrokeJoin join,
    PathEffect pathEffect
)

Public methods

boolean
equals(Object other)
final @NonNull StrokeCap

Return the paint's Cap, controlling how the start and end of stroked lines and paths are treated.

final @NonNull StrokeJoin

Set's the treatment where lines and curve segments join on a stroked path.

final float

Set the stroke miter value.

final PathEffect

Effect to apply to the stroke, null indicates a solid stroke line is to be drawn

final float

Configure the width of the stroke in pixels

int
@NonNull String

Constants

DefaultMiter

public static final float DefaultMiter = 4.0f

Default miter length used in combination with joins

HairlineWidth

public static final float HairlineWidth = 0.0f

Width to indicate a hairline stroke of 1 pixel

Public constructors

Stroke

public Stroke(
    float width,
    float miter,
    @NonNull StrokeCap cap,
    @NonNull StrokeJoin join,
    PathEffect pathEffect
)
Parameters
float width

Configure the width of the stroke in pixels

float miter

Set the stroke miter value. This is used to control the behavior of miter joins when the joins angle is sharp. This value must be >= 0

@NonNull StrokeCap cap

Return the paint's Cap, controlling how the start and end of stroked lines and paths are treated. The default is StrokeCap.Butt

@NonNull StrokeJoin join

Set's the treatment where lines and curve segments join on a stroked path. The default is StrokeJoin.Miter

PathEffect pathEffect

Effect to apply to the stroke, null indicates a solid stroke line is to be drawn

Public methods

equals

public boolean equals(Object other)

getCap

public final @NonNull StrokeCap getCap()

Return the paint's Cap, controlling how the start and end of stroked lines and paths are treated. The default is StrokeCap.Butt

getJoin

public final @NonNull StrokeJoin getJoin()

Set's the treatment where lines and curve segments join on a stroked path. The default is StrokeJoin.Miter

getMiter

public final float getMiter()

Set the stroke miter value. This is used to control the behavior of miter joins when the joins angle is sharp. This value must be >= 0

getPathEffect

public final PathEffect getPathEffect()

Effect to apply to the stroke, null indicates a solid stroke line is to be drawn

getWidth

public final float getWidth()

Configure the width of the stroke in pixels

hashCode

public int hashCode()

toString

public @NonNull String toString()