开发者

(Android) Draw image outside the view class (canvas access?)

开发者 https://www.devze.com 2023-02-14 21:45 出处:网络
I\'d like to make a Library containing an override class of View(eg: MyView extends View) and want to make a method \"Draw(String FileName)\".

I'd like to make a Library containing an override class of View(eg: MyView extends View) and want to make a method "Draw(String FileName)".

So what I ultimately want to do is to simply import this library and call this "Draw(String FileName)" method to draw an image from other activities.

I've tried by myself, but I encountered some problem with accessing main Canvas which onDraw() method actually has.

It would be easy if I just draw every image in onDraw() method function, but I 开发者_C百科have no idea how to put things from outside the class.

any idea for this structure?


OK, I solved my problem but I'm not sure this is the best way.

I made an interface call back function inside the class which inherits View, and I could access the Draw() method by using that call back.

0

精彩评论

暂无评论...
验证码 换一张
取 消