-
Notifications
You must be signed in to change notification settings - Fork 157
1.2 Using DrawView
Oscar Gilberto Medina Cruz edited this page May 6, 2017
·
2 revisions
For using DrawView you need to add to your layout file
<com.byox.drawview.views.DrawView
android:id="@+id/draw_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>From your java code, get the view from your layout for using later.
public class MainActivity extends AppCompatActivity {
private DrawView mDrawView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
...
mDrawView = (DrawView) findViewById(R.id.draw_view);
...
}
}And you can set the OnDrawViewListener for controlling draw life cycle, in order:
- onStartDrawing when you tap down in screen.
- onEndDrawing when you tap up in screen.
- onClearDrawing when your screen has been cleared.
- onRequestText is executed when your DrawView has configured with text mode, and you tap up your screen for requesting for a text.
- onAllMovesPainted is triggered when all the user actions are completely drawn
mDrawView.setOnDrawViewListener(new DrawView.OnDrawViewListener() {
@Override
public void onStartDrawing() {
// Your stuff here
}
@Override
public void onEndDrawing() {
// Your stuff here
}
@Override
public void onClearDrawing() {
// Your stuff here
}
@Override
public void onRequestText() {
// Your stuff here
}
@Override
public void onAllMovesPainted() {
// Your stuff here
}
}