Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
DonghanX authored Jun 16, 2022
1 parent 80393b3 commit 7433d34
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,40 @@ dependencies {
* Save the Canvas as Bitmap.

## Usage
#### Include `DrawView` in your layout.xml

### Setup:

#### Include `DrawView` in your layout.xml directly
```XML
<com.redhoodhan.draw.DrawView
android:id="@+id/draw_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
```

#### (Alternatively) Include `DrawView` in your layout.xml with custom attributes setting
```XML
<com.redhoodhan.draw.DrawView
android:id="@+id/draw_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultBrushColor="@color/purple"
app:defaultBrushSize="20F"
app:defaultCanvasBackgroundImageRes="@drawable/img_draw_background_1"
app:defaultEraserSize="15F" />
```

| Attribute Name | Format | Description |
| :----: | :----: | :----: |
| defaultBrushSize | Float | The default value of brush size |
| defaultEraserSize | Float | The default value of eraser size |
| defaultBrushColor | Color | The default stroke color of brush paint |
| defaultCanvasBackgroundColor | Color | The default color of canvas background |
| defaultCanvasBackgroundImageRes | Reference | The default image resource ID of canvas background|
> Note that setting `defaultCanvasBackgroundImageRes` will override the effect of `defaultCanvasBackgroundColor`.
### Further Usage:

#### (Optional) Implement the callbacks
* `drawViewPressCallback`: Invoked when you press the `DrawView`.
* `undoStateCallback` / `redoStateCallback`: Invoked when the content in the `DrawView` changes. The given receiver parameter returns true if Undo / Redo action is available after the change.
Expand All @@ -74,7 +100,6 @@ binding.drawView.lineType = LineType.SOLID
```
`LineType` is utilized by `DrawView` to modify the path properties and paint options, such as `StrokeStyle`, `Alpha` and `PathEffect`.

The `LineType` enum value and its description are as follows:
| LineType | Description |
| :----: | :----: |
| LineType.SOLID | Solid line |
Expand Down

0 comments on commit 7433d34

Please sign in to comment.