public class Keyline extends java.lang.Object implements RhythmSpecLayer
Fill
inside an Inset
for the latter. The keyline is drawn
towards the specified edge by default (i.e. touching aligned child views), but this can be tweaked using setAlignOutside(boolean)
method.Modifier and Type | Class and Description |
---|---|
static class |
Keyline.Factory
|
Modifier and Type | Field and Description |
---|---|
static boolean |
ALIGN_INSIDE |
static boolean |
ALIGN_OUTSIDE |
static int |
DEFAULT_KEYLINE_COLOR |
static int |
DEFAULT_THICKNESS
Default keyline thickness (2px)
|
protected boolean |
mAlignOutside |
protected int |
mDistance |
protected int |
mEdgeAffinity |
protected android.graphics.Paint |
mPaint |
protected int |
mThickness |
Modifier | Constructor and Description |
---|---|
protected |
Keyline()
Create a layer that draws a horizontal or vertical keyline at a specified distance from required edge.
|
|
Keyline(int edgeAffinity,
int distance)
Create a layer that draws a horizontal or vertical keyline at a specified distance from required edge
|
Modifier and Type | Method and Description |
---|---|
void |
draw(android.graphics.Canvas canvas,
android.graphics.Rect drawableBounds)
Draw itself to the provided canvas within provided bounds according to internal configuration (if any)
|
Keyline |
setAlignOutside(boolean alignOutside)
Set keyline alignment.
|
Keyline |
setColor(int color)
Set keyline color
|
Keyline |
setDistance(int distance)
Set the distance of the keyline from specified edge
|
Keyline |
setEdgeAffinity(int edgeAffinity)
Set edge affinity of the keyline
|
Keyline |
setThickness(int thickness)
Set keyline thickness
|
public static final int DEFAULT_KEYLINE_COLOR
public static final int DEFAULT_THICKNESS
public static final boolean ALIGN_INSIDE
public static final boolean ALIGN_OUTSIDE
protected int mEdgeAffinity
protected int mDistance
protected int mThickness
protected boolean mAlignOutside
protected android.graphics.Paint mPaint
public Keyline(int edgeAffinity, int distance)
edgeAffinity
- Defines the edge of the view this keyline must be anchored to. Values (Gravity.LEFT
and Gravity.RIGHT
) will result in a vertical keyline, and values (Gravity.TOP
and Gravity.BOTTOM
) will result in a horizontal keyline.distance
- Distance of this keyline from the specified edge, in pixelssetAlignOutside(boolean)
protected Keyline()
Create a layer that draws a horizontal or vertical keyline at a specified distance from required edge.
This is a minimum constructor for the factory — only paints and reusable objects are initialized. Developers extending this class are responsible for setting all fields to proper argument values.
public Keyline setDistance(int distance)
distance
- Distance of this keyline from the specified edge, in pixelspublic Keyline setEdgeAffinity(int edgeAffinity)
edgeAffinity
- Defines the edge of the view this keyline must be anchored to. Values (Gravity.LEFT
and Gravity.RIGHT
) will result in a vertical keyline, and values (Gravity.TOP
and Gravity.BOTTOM
) will result in a horizontal keyline.public Keyline setColor(int color)
color
- Grid line color, in #AARRGGBB format as usualpublic Keyline setThickness(int thickness)
thickness
- Keyline thickness, in pixels. For keylines keep thickness around a few pixels, whereas for
highlights feel free to use as many dips as required.setAlignOutside(boolean)
public Keyline setAlignOutside(boolean alignOutside)
alignOutside
- either false
(ALIGN_INSIDE
, default) for the keyline to extend towards
the edge defined by edge affinity, or true
(ALIGN_OUTSIDE
) to extend
away from the edgepublic void draw(android.graphics.Canvas canvas, android.graphics.Rect drawableBounds)
RhythmSpecLayer
draw
in interface RhythmSpecLayer
canvas
- Canvas for the layer to draw itself todrawableBounds
- Bounds where this layer should draw itself. Since these are the bounds of a RhythmDrawable
connected to the view, they are usually the same as the view’s bounds, so
you can use this parameter to get the view’s dimensions should you need them.