NativeScript - Bitmap & Canvas

三世轮回 提交于 2019-12-10 18:23:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!