问题
I am new in nativescript app development. I want to use android.graphics.Bitmap
and android.graphics.Canvas
in NativeScript. I googled for creating bitmap and draw it using canvas, but didn't find any solution. Basically i want to draw rectangle. Please help me!
Thanks in advance :)
This is the result from Android app and same is required to implement on NativeScript.
回答1:
For the canvas your javascript would need to be something like:
var canvas = new android.graphics.Canvas();
that would construct an empty canvas.
The same goes for the Bitmap, you could use the NativeScript image module which uses bitmaps under the abstraction. Another option is you could achieve all of this without any native android calls and just use the NS image on your main layout. Then use the gestures module to drag in that other image.
This post from the NS team might help you more than anything with writing the native android/java in javascript for a NativeScript app though. https://docs.nativescript.org/runtimes/android/marshalling/java-to-js.html
来源:https://stackoverflow.com/questions/37724634/nativescript-bitmap-canvas