在Android中,如何设置画布大小?

时间:2022-12-26 23:42:55

I have a frame that is 100% width and the height is also 100% of the width. (If screen is 480 pixels wide, that means the width and height of the frame are 480 pixels wide.)

我的框架宽度为100%,高度也是宽度的100%。 (如果屏幕宽度为480像素,则表示框架的宽度和高度为480像素宽。)

I'm writing an image editing appkication, and I need the frame to be the only place that a user can draw on. Is there a way I can resize and position the Canvas to the frame?

我正在编写一个图像编辑应用程序,我需要框架是用户可以绘制的唯一地方。有没有办法我可以调整画布的大小和位置?

1 个解决方案

#1


0  

You can dynamically add a SurfaceView (or a View) of desired dimensions to your root layout and get that SurfaceView's Canvas.

您可以动态地将所需尺寸的SurfaceView(或视图)添加到根布局,并获取SurfaceView的Canvas。

#1


0  

You can dynamically add a SurfaceView (or a View) of desired dimensions to your root layout and get that SurfaceView's Canvas.

您可以动态地将所需尺寸的SurfaceView(或视图)添加到根布局,并获取SurfaceView的Canvas。