Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 1.0.0
belongs to Maven artifact androidx.appcompat:appcompat:1.0.0-rc01

DrawerArrowDrawable

public class DrawerArrowDrawable
extends Drawable

java.lang.Object
   ↳ android.graphics.drawable.Drawable
     ↳ androidx.appcompat.graphics.drawable.DrawerArrowDrawable


A drawable that can draw a "Drawer hamburger" menu or an arrow and animate between them.

The progress between the two states is controlled via setProgress(float).

Summary

Constants

int ARROW_DIRECTION_END

Direction to make the arrow point to the end.

int ARROW_DIRECTION_LEFT

Direction to make the arrow point towards the left.

int ARROW_DIRECTION_RIGHT

Direction to make the arrow point towards the right.

int ARROW_DIRECTION_START

Direction to make the arrow point towards the start.

Public constructors

DrawerArrowDrawable(Context context)

Public methods

void draw(Canvas canvas)
float getArrowHeadLength()

Returns the length of the arrow head (from tip to edge, perpendicular to the shaft), in pixels.

float getArrowShaftLength()

Returns the arrow shaft length in pixels.

float getBarLength()

The length of the bars when they are parallel to each other.

float getBarThickness()

Returns the thickness (stroke width) of the bars.

int getColor()

Returns the color of the drawable.

int getDirection()

Returns the arrow direction.

float getGapSize()

Returns the max gap between the bars when they are parallel to each other.

int getIntrinsicHeight()
int getIntrinsicWidth()
int getOpacity()
final Paint getPaint()

Returns the paint instance used for all drawing.

float getProgress()

Returns the current progress of the arrow.

boolean isSpinEnabled()

Returns whether the bars should rotate or not during the transition.

void setAlpha(int alpha)
void setArrowHeadLength(float length)

Sets the length of the arrow head (from tip to edge, perpendicular to the shaft).

void setArrowShaftLength(float length)

Sets the arrow shaft length.

void setBarLength(float length)

Sets the length of the bars when they are parallel to each other.

void setBarThickness(float width)

Sets the thickness (stroke size) for the bars.

void setColor(int color)

Sets the color of the drawable.

void setColorFilter(ColorFilter colorFilter)
void setDirection(int direction)

Set the arrow direction.

void setGapSize(float gap)

Sets the max gap between the bars when they are parallel to each other.

void setProgress(float progress)

Set the progress of the arrow.

void setSpinEnabled(boolean enabled)

Returns whether the bars should rotate or not during the transition.

void setVerticalMirror(boolean verticalMirror)

If set, canvas is flipped when progress reached to end and going back to start.

Inherited methods

Constants

ARROW_DIRECTION_END

added in version 1.0.0
public static final int ARROW_DIRECTION_END

Direction to make the arrow point to the end.

When used in a view with a RTL layout direction, this is the same as ARROW_DIRECTION_LEFT, otherwise it is the same as ARROW_DIRECTION_RIGHT.

Constant Value: 3 (0x00000003)

ARROW_DIRECTION_LEFT

added in version 1.0.0
public static final int ARROW_DIRECTION_LEFT

Direction to make the arrow point towards the left.

Constant Value: 0 (0x00000000)

ARROW_DIRECTION_RIGHT

added in version 1.0.0
public static final int ARROW_DIRECTION_RIGHT

Direction to make the arrow point towards the right.

Constant Value: 1 (0x00000001)

ARROW_DIRECTION_START

added in version 1.0.0
public static final int ARROW_DIRECTION_START

Direction to make the arrow point towards the start.

When used in a view with a RTL layout direction, this is the same as ARROW_DIRECTION_RIGHT, otherwise it is the same as ARROW_DIRECTION_LEFT.

Constant Value: 2 (0x00000002)

Public constructors

DrawerArrowDrawable

added in version 1.0.0
public DrawerArrowDrawable (Context context)

Parameters
context Context: used to get the configuration for the drawable from

Public methods

draw

added in version 1.0.0
public void draw (Canvas canvas)

Parameters
canvas Canvas

getArrowHeadLength

added in version 1.0.0
public float getArrowHeadLength ()

Returns the length of the arrow head (from tip to edge, perpendicular to the shaft), in pixels.

Returns
float

getArrowShaftLength

added in version 1.0.0
public float getArrowShaftLength ()

Returns the arrow shaft length in pixels.

Returns
float

getBarLength

added in version 1.0.0
public float getBarLength ()

The length of the bars when they are parallel to each other.

Returns
float

getBarThickness

added in version 1.0.0
public float getBarThickness ()

Returns the thickness (stroke width) of the bars.

Returns
float

getColor

added in version 1.0.0
public int getColor ()

Returns the color of the drawable.

Returns
int

getDirection

added in version 1.0.0
public int getDirection ()

Returns the arrow direction.

Returns
int

getGapSize

added in version 1.0.0
public float getGapSize ()

Returns the max gap between the bars when they are parallel to each other.

Returns
float

See also:

getIntrinsicHeight

public int getIntrinsicHeight ()

Returns
int

getIntrinsicWidth

public int getIntrinsicWidth ()

Returns
int

getOpacity

added in version 1.0.0
public int getOpacity ()

Returns
int

getPaint

added in version 1.0.0
public final Paint getPaint ()

Returns the paint instance used for all drawing.

Returns
Paint

getProgress

added in version 1.0.0
public float getProgress ()

Returns the current progress of the arrow.

Returns
float

Value is between 0.0 and 1.0 inclusive.

isSpinEnabled

added in version 1.0.0
public boolean isSpinEnabled ()

Returns whether the bars should rotate or not during the transition.

Returns
boolean

setAlpha

added in version 1.0.0
public void setAlpha (int alpha)

Parameters
alpha int

setArrowHeadLength

added in version 1.0.0
public void setArrowHeadLength (float length)

Sets the length of the arrow head (from tip to edge, perpendicular to the shaft).

Parameters
length float: the length in pixels

setArrowShaftLength

added in version 1.0.0
public void setArrowShaftLength (float length)

Sets the arrow shaft length.

Parameters
length float: the length in pixels

setBarLength

added in version 1.0.0
public void setBarLength (float length)

Sets the length of the bars when they are parallel to each other.

Parameters
length float: the length in pixels

setBarThickness

added in version 1.0.0
public void setBarThickness (float width)

Sets the thickness (stroke size) for the bars.

Parameters
width float: stroke width in pixels

setColor

added in version 1.0.0
public void setColor (int color)

Sets the color of the drawable.

Parameters
color int

setColorFilter

added in version 1.0.0
public void setColorFilter (ColorFilter colorFilter)

Parameters
colorFilter ColorFilter

setDirection

added in version 1.0.0
public void setDirection (int direction)

Set the arrow direction.

Parameters
direction int

setGapSize

added in version 1.0.0
public void setGapSize (float gap)

Sets the max gap between the bars when they are parallel to each other.

Parameters
gap float: the gap in pixels

See also:

setProgress

added in version 1.0.0
public void setProgress (float progress)

Set the progress of the arrow.

A value of 0.0 indicates that the arrow should be drawn in its starting position. A value of 1.0 indicates that the arrow should be drawn in its ending position.

Parameters
progress float

Value is between 0.0 and 1.0 inclusive.

setSpinEnabled

added in version 1.0.0
public void setSpinEnabled (boolean enabled)

Returns whether the bars should rotate or not during the transition.

Parameters
enabled boolean: true if the bars should rotate.

See also:

setVerticalMirror

added in version 1.0.0
public void setVerticalMirror (boolean verticalMirror)

If set, canvas is flipped when progress reached to end and going back to start.

Parameters
verticalMirror boolean