surfaceview

Android draw using SurfaceView and Thread

跟風遠走 提交于 2019-11-30 08:21:26
问题 I am trying to draw a ball to my screen using 3 classes. I have read a little about this and I found a code snippet that works using the 3 classes on one page, Playing with graphics in Android I altered the code so that I have a ball that is moving and shifts direction when hitting the wall like the picture below (this is using the code in the link) . Now I like to separate the classes into 3 different pages for not making everything so crowded, everything is set up the same way. Here are the

Camera preview stretched even after setting the correct dimensions

妖精的绣舞 提交于 2019-11-30 08:16:52
I'm creating a camera app that implements it's own camera preview for taking pictures. The app is currently forced into portrait mode. My problem is that the preview from the camera is slightly stretched (the aspect ratio is a bit off). The funny thing is that I'm setting my SurfaceView size to always match the preview size. This ensures that the aspect ratio should always be perserved... but it isn't... Here is the layout i use to show my camera preview: public class Cp extends ViewGroup implements SurfaceHolder.Callback { private final String TAG = "CameraPreview"; private boolean

How to properly use setZOrderMediaOverlay on Android?

你。 提交于 2019-11-30 07:17:59
Like many others, I am trying to draw 3D objects (using GLSurfaceView) on camera preview (using SurfaceView), along with some buttons placed on top. I actually got a prototype working, but I could not get the onResume working correctly. After a resume, GLSurfaceView stays behind and is not visible anymore. I know that it is working, because I can see the drawing fine if I remove the SurfaceView from the layout. The target is Nexus One, running stock 2.3.3 ROM. Here's the layout xml: <com.example.cameratest.GLPreview android:id="@+id/cubes" android:layout_width="fill_parent" android:layout

How to make SurfaceView with transparent background?

☆樱花仙子☆ 提交于 2019-11-30 07:13:40
I have simple layout <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/RelativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/backgroundtimer" android:orientation="vertical" > <TextView android:id="@+id/TextView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="@string/hello" /> <com.fmech.zenclock.surface.ZenClockSurface android:id="@+id

Android Camera(二)

亡梦爱人 提交于 2019-11-30 06:49:10
Android Camera 一文简单介绍了如何在自己的App里实时显示Camera,但有时我们的App不只是要显示图像,可能还要添加其他信息,如在指定位置画Rectangle等等。 stackoverflow 中有人问到如何在camera的SurfaceView中画矩形,最后,提问者根据别人的 建议给出了如下答案: 新建一个与Camera重叠的SurfaceView,然后将该SurfaceView设置透明背景,然后就可以绘制你想绘制的代码图形了。 我测试了下,发现,新建View也是可以的。 layout如下: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/camera_preview" android:layout_width="320dp" android:layout_height="240dp" /> <view.TestView android:id="@+id/TransparentView"

Adding GestureOverlayView to my SurfaceView class, how to add to view hierarchy?

南笙酒味 提交于 2019-11-30 05:31:05
I was informed in a later answer that I have to add the GestureOverlayView I create in code to my view hierarchy, and I am not 100% how to do that. Below is the original question for completeness. I want my game to be able to recognize gestures. I have this nice SurfaceView class that I do an onDraw to draw my sprites, and I have a thread thats running it to call the onDraw etc . This all works great. I am trying to add the GestureOverlayView to this and it just isn't working. Finally hacked to where it doesn't crash but this is what i have public class Panel extends SurfaceView implements

Android: Supported Camera Preview Size Is Wrong Aspect Ratio

给你一囗甜甜゛ 提交于 2019-11-30 05:24:49
问题 Solution: I was not actually setting the camera preview but rather scaling the default preview it came with. You need to assign the parameters back to the camera, because _camera.getParamters.setPreviewSize() does not work! I am working on getting Android cameras to preview on my phone (ideally fullscreen). However I've run into a situation where I feel both the hardware and software are conspiring against me :/ I get a list of camera supported screen sizes. For half the phones (about 6 of my

BufferQueue has been abandoned: When playing video with TextureView

不想你离开。 提交于 2019-11-30 05:09:02
Every time I pause my activity (actually Fragment) to go to another app, upon returning with onResume I try to resume the video playing but it does not play: I get a blank screen. Upon investigation, I see the following in the Logcat E/BufferQueueProducer: [unnamed-23827-0] queueBuffer: BufferQueue has been abandoned E/MediaPlayer: error (1, -38) E/MediaPlayer: error (1, -38) E/MediaPlayer: error (1, -38) E/MediaPlayer: error (1, -38) E/BufferQueueProducer: [unnamed-23827-0] connect(P): BufferQueue has been abandoned Here is the code I call inside on resume player.seekTo(mVideoSeekPosition);

draw only a portion of a Drawable/Bitmap

梦想的初衷 提交于 2019-11-30 04:48:23
问题 I was wondering if it is possible to draw only a portion of a bitmap after it is loaded into memory without creating a new Bitmap. I see Drawable has a setBounds method but im not sure if it only draws the area set or just resizes the entire image. Thank you. 回答1: Assuming you have a main canvas to draw to, you can use one of the drawBitmap methods of the Canvas class to draw a subset of the loaded bitmap. public void drawBitmap (Bitmap bitmap, Rect src, Rect dst, Paint paint) 回答2: I searched

Set Background color of Surface View

蹲街弑〆低调 提交于 2019-11-30 02:40:42
问题 I want to set a background color to the surface view to my camera surface view. I am using this for implementing the same. But this example is not complete. Can anyone please help me with some other useful link. Thanks 回答1: There's a workaround to do this. add a parent viewgroup for the surfaceview, set the background color to this viewgroup instead of the surfaceview; <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/holo