Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,如何在 CameraPreview (SurfaceView) 内绘制一个矩形?在 setPreviewCallback 中,我实现了应该调用 onDraw 方法的 invalidate 方法。但是什么也没发生。任何人都可以帮忙吗?
我将尝试回答我自己的问题。我创建了一个扩展类 View 的新类。在其中我实现了画布对象的一部分和 onDraw 方法。在此之后,我从新类的 Type 在主 Activity 中创建了一个 Object。使用方法 addContentView(View v, LayoutParam...) 我添加了新视图。就是这样。现在将在 SurfaceView 上绘制新创建的视图。
希望这会帮助其他有同样问题的人。