Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the deformation of Android SurfaceView preview

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to solve Android SurfaceView preview deformation". In daily operation, I believe many people have doubts about how to solve the problem of Android SurfaceView preview deformation. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to solve Android SurfaceView preview deformation". Next, please follow the editor to study!

Take a look at the following callback:

@ Override public void surfaceChanged (SurfaceHolder holder, int format, int width, int height) {Log.i (TAG, "surfaceChanged:" + width + "" + height);}

From the data printed in the callback above, we know that taking a similar proportion will not solve the fundamental problem.

So, for this kind of solution, I just want to say that it is only useful to be close.

Now that you know that the width and height of surfaceChanged is the width and height of SurfaceView rendering, you just need to find a way to make the aspect ratio in surfaceChanged the same as that of camera. So look at the source code of SurfaceView:

Protected void updateWindow (boolean force, boolean redrawNeeded) {... The code omits int myWidth = mRequestedWidth; if (myWidth

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 257

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report