-
Notifications
You must be signed in to change notification settings - Fork 157
1.4 Attributes
You can configure your DrawView from layout or directly from java code.
For configuring from layout, use a custom attributes.
app:dv_draw_alpha="255"
: the transparency of the draw color
app:dv_draw_anti_alias="true"
: use the anti alias value for the draw
app:dv_draw_color="@color/colorAccent"
: the color using for the draw
app:dv_draw_corners="round"
: the corners of the line we are drawing. This value can be butt, round, or square.
app:dv_draw_dither="true"
: use the dither value for the draw
app:dv_draw_font_family="default_font"
: the font family used for draw the text. This value can be default_font, monospace, sans_serif, or serif.
app:dv_draw_font_size="12"
: the font size.
app:dv_draw_mode="draw"
: defines the draw mode of the view, you can draw, add some text or erase the current content. This value can be draw, text, or eraser,.
app:dv_draw_style="stroke"
: defines the draw style of the view, you can draw with a fill style, with a stroke or with a combination of both. This value can be fill, fill_stroke, or stroke.
app:dv_draw_tool="pen"
: defines the draw tool that be used for draw. This value can be pen, line, rectangle, or circle.
app:dv_draw_width="4"
: The current with of the draw.
dv_draw_enable_zoom="true"
: Enable the zoom for the drawview.
dv_draw_max_zoom_factor="15"
: Assign the max zoom factor for the drawview
dv_draw_zoomregion_scale="4"
: Assign the scale of the mini draw preview
dv_draw_zoomregion_minscale="4"
: Assign the minimum scale of the mini draw preview
dv_draw_zoomregion_maxscale="4"
: Assign the maximum scale of the mini draw preview
Or if you prefer, assign the values using java methods.
mDrawView.setDrawColor(newPaint.getColor())
.setPaintStyle(newPaint.getStyle())
.setDither(newPaint.isDither())
.setDrawWidth((int) newPaint.getStrokeWidth())
.setDrawAlpha(newPaint.getAlpha())
.setAntiAlias(newPaint.isAntiAlias())
.setLineCap(newPaint.getStrokeCap())
.setFontFamily(newPaint.getTypeface())
.setFontSize(newPaint.getTextSize())
.setZoomEnabled(true)
.setMaxZoomFactor(15)
.setZoomRegionScale(4)
.setZoomRegionScaleMin(2)
.setZoomRegionScaleMax(5);
I use a new Paint instance and read all the attributes from that, but you can assign it directly.