surfaceview

Size of a Canvas in a Surfaceview against real screen resolution

人盡茶涼 提交于 2019-12-24 08:07:51
问题 I am trying to use the SurfaceView and the Canvas to make some draws, in my 480x800 phone, but I do not understand how this is managed, because when I display canvas size, it show 320x533 ( while my screen is 480x800 ) I tryied to use setFixedSize() on the getHolder to reset the canvas resolution, seems to work fine, but is it a correct way to do such resize ? Another trouble is getting the touch event coordinates, while my canvas seem to be resized, to touch events are still matched against

How to invoke drag event of a custom view inside SurfaceView?

↘锁芯ラ 提交于 2019-12-24 06:48:09
问题 How can i drag a custom view inside the SurfaceView. Touch events are not dispatched to child custom view from SurfaceView or child view's onTouchEvent is not called. 回答1: Try this code public class MoveViewTouchListener implements View.OnTouchListener { private GestureDetector mGestureDetector; private View mView; public MoveViewTouchListener(View view) { mGestureDetector = new GestureDetector(view.getContext(), mGestureListener); mView = view; } @Override public boolean onTouch(View v,

How to invoke drag event of a custom view inside SurfaceView?

﹥>﹥吖頭↗ 提交于 2019-12-24 06:47:16
问题 How can i drag a custom view inside the SurfaceView. Touch events are not dispatched to child custom view from SurfaceView or child view's onTouchEvent is not called. 回答1: Try this code public class MoveViewTouchListener implements View.OnTouchListener { private GestureDetector mGestureDetector; private View mView; public MoveViewTouchListener(View view) { mGestureDetector = new GestureDetector(view.getContext(), mGestureListener); mView = view; } @Override public boolean onTouch(View v,

(RK3399)使用TextureView+MediaPlayer实现视频播放器

做~自己de王妃 提交于 2019-12-24 05:09:48
(RK3399)使用TextureView+MediaPlayer实现视频播放器 为何使用TextureView SurfaceView TextureView 遇到的问题 测试 总结 为何使用TextureView 原因是公司导师要求,原本RkVideoPlayer是用的SurfaceView,现在给我的任务就是使用TextureView来替换SurfaceView。原因是原本使用SurfaceView,在播放中按电源键休眠,再打开,视频会暂停,不会继续播放,所以替换成TextureView看看是不是能继续播放。那么就先来看一下TextureView和SurfaceView的区别吧。 SurfaceView和TextureView均继承于android.view.View,与其它View不同的是,两者都能在独立的线程中绘制和渲染,在专用的GPU线程中大大提高渲染的性能。 对于SurfaceView来说,1.不能加上动画、平移、缩放;2.两个SurfaceView不能相互覆盖; 而TextureView更像是一般的View,像TextView那样能被缩放、平移,也能加上动画,还有必须在开启了硬件加速的window里使用。 弄清楚了这俩的区别以后,就开始研究研究具体如何替换吧。 SurfaceView public class VideoDisplayView extends

Creating circle in SurfaceView on button click android

こ雲淡風輕ζ 提交于 2019-12-24 04:12:26
问题 So essentially I am working on an app that creates a circle withing a SurfaceView. I want for a new circle to be generated inside the SurfaceView whenever pressing the "create" button. Each new circle would have a random speed, color, starting position along with a unique sequence number. It's easy enough to create a circle with a random color and starting position, but I was having some trouble getting the circle to draw only when I click on the create button. Whenever I try to create a

How to partially redraw custom SurfaceView using separate thread without losing previous edits?

青春壹個敷衍的年華 提交于 2019-12-24 00:29:14
问题 I am currently having trouble with drawing to a custom SurfaceView from a thread that is not on my main UI. This SurfaceView takes up the entirety of the screen (Galaxy S3 in full screen) and must be updated from several sources. The problem is that the custom SurfaceView will not save changes between updates to UI. The custom SurfaceView class is defined within the activity that uses it, and the thread (let's call it DrawingThread ) that runs periodic checks for updates is defined within the

Android: Implement admob on surfaceview

本小妞迷上赌 提交于 2019-12-23 19:09:09
问题 I have an activity in form of a small game which uses SurfaceView. Below are the code snippets.. I am confused how to implement admob on surfaceview. Please suggest. public class DroidzActivity extends Activity { private static final String TAG = DroidzActivity.class.getSimpleName(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // requesting to turn the title OFF requestWindowFeature(Window.FEATURE_NO_TITLE); // making it full screen

Accessing the Camera from com.google.android.gms.vision.CameraSource and Increasing/Decreasing the Preview Brightness

那年仲夏 提交于 2019-12-23 18:54:12
问题 I Have to implement in Google Vision API's CameraSource for build the camera and do the face detection on before capturing the image. Now I have faced few issues, So I need to access the camera object from CameraSource. How could I achieve the increase or Decrease the Camera Preview Brightness using CameraSource? This is my CameraSource Builder mCameraSource = new CameraSource.Builder(context, detector) .setRequestedPreviewSize(640, 480) .setFacing(CameraSource.CAMERA_FACING_FRONT)

SurfaceView setMeasuredDimension() with height greater than 4096 crashes

给你一囗甜甜゛ 提交于 2019-12-23 17:37:01
问题 I'm using surfaceview in my work. My requirement is to make a curved line in a vertical scrollview. When I test it I found when the height is less than 4096 it works well, but more than that (even just 4097), it crashes! @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // TODO Auto-generated method stub super.onMeasure(widthMeasureSpec, heightMeasureSpec); setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), 4097); } Can anyone tell me why? 回答1: The

Android multiple camera preview

一个人想着一个人 提交于 2019-12-23 12:44:09
问题 Is it possible to broadcast the android camera preview into 2 different SurfaceView controls at the same time? I have seen some apps that show effects into different previews in real-time, how do they achieve that? I read about the TextureView, is this the view to use? where can I find examples of multiple simultaneous camera previews? Thanks 回答1: I don't think that it is possible to independently open 2 camera previews at the same time, as the camera is treated as a shared resource. However,