surfaceview

Implementing Admob banner when setContentView() is used for the Surfaceview

北城余情 提交于 2019-12-02 18:15:02
问题 I am struggling to implement an admob banner into my app because the setContentView() method is used for the surfaceView called gameView so creating the adView in xml cannot be applied to this framework as setContentView is already being used. And I don't know how to do this programmatically. Does anyone have a solution to this? My main Activity: public class GameMainActivity extends BaseGameActivity { .... @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate

How do I use Android’s “Surface” classes?

旧时模样 提交于 2019-12-02 17:38:36
Is there a detailed explanation of Surface, SurfaceHolder, EGLSurface, SurfaceView, GLSurfaceView, SurfaceTexture, and TextureView? In particular: What’s the difference between SurfaceView and TextureView? Do I need to use GLSurfaceView to use OpenGL ES? How do Surface and EGLSurface interact? What does SurfaceTexture do? Why does the stuff I draw on a SurfaceView have to go above or below everything else? What is SurfaceFlinger? How does composition of the status and navigation bars work? While we’re at it, what’s the right way to structure a game loop on Android? The answers to these and

Overlay a static drawable image over camera preview

拟墨画扇 提交于 2019-12-02 17:00:12
问题 I need to display a static .png image while my mobile is in the camera preview mode.As for now I am referencing this link [a link]Overlay images onto Camera preview SurfaceView . and this link to display the camera preview screen[a link]http://android-er.blogspot.com.au/2010/12/add-overlay-on-camera-preview.html. Please suggest to proceed further.Thanks. 回答1: Put the camera's preview SurfaceView and an ImageView into a FrameLayout or a RelativeLayout. The SurfaceView must be first in the

Move an object on on a Bézier curve path

喜你入骨 提交于 2019-12-02 16:01:14
I want to move my image on a Bézier curve path from top to bottom but I can't get how can I calculate x/y points and slope from this path. The path looks like the following image: I have start points, end points and two control points. Path path = new Path(); Point s = new Point(150, 5); Point cp1 = new Point(140, 125); Point cp2 = new Point(145, 150); Point e = new Point(200, 250); path.moveTo(s.x, s.y); path.cubicTo(cp1.x, cp1.y, cp2.x, cp2.y, e.x, e.y); This is a cubic Bézier curve for which the formula is simply [x,y]=(1–t)^3*P0+3(1–t)^2*t*P1+3(1–t)t^2*P2+t^3*P3 . With this you can solve

Android IllegalThreadStateException in LunarLander

半城伤御伤魂 提交于 2019-12-02 13:51:40
问题 Just come to polishing my application and making it resume after the user has left. When the application restores I get an IllegalThreadStateException, which is quite annoying. This problem is present in the example google gives of Lunar Lander. Has anyone found a way to restore working when using surfaceView? 回答1: I believe this arises from a disparity in how the Surface and the Activity are handled. When you leave the LunarLander application the surface is destroyed (invoking

Unable to draw on top of a custom SurfaceView class

妖精的绣舞 提交于 2019-12-02 07:25:51
问题 I've used the example guide to create a class called CameraPreview which inherits from the SurfaceView class, and which displays the camera preview. I've also created another custom view class called DrawOnTop which just inherits directly from View, and I use this for drawing text and other items on top of the preview. Each view class works fine on its own, but when I load both views into the activity, the CameraPreview always dominates and none of the objects or text from the DrawOnTop class

Run SurfaceView off UI Thread

核能气质少年 提交于 2019-12-02 07:22:17
问题 My surfraceview is where the majority of my application is and I would like to reduce its lag, thus I have been told to take it off the UI Thread. Is it possible to run a SurfaceView in an AsyncTask? 回答1: While it is possible to draw into a SurfaceView from an AsyncTask it is not recommended. AsyncTasks can run in a serial queue so you would likely block other tasks. Instead just use a Thread. The SDK contains a sample app called LunarLander which shows how to do this. 来源: https:/

how to set backgroundColor to a surfaceview in android?

≯℡__Kan透↙ 提交于 2019-12-02 05:24:35
问题 i am using a surface view to draw interactive piechart. here is my code which will looks like all surface view examples. class PieChart extends SurfaceView implements SurfaceHolder.Callback { public PieChart(Context context) { super(context); // Log.i("PieChart", "PieChart : constructor"); getHolder().addCallback(this); } @Override public void onDraw(Canvas canvas) { if (hasData) { resetColor(); try { canvas.drawColor(getResources().getColor(R.color.graphbg_color)); graphDraw(canvas); } catch

Unable to draw on top of a custom SurfaceView class

烂漫一生 提交于 2019-12-02 03:49:18
I've used the example guide to create a class called CameraPreview which inherits from the SurfaceView class, and which displays the camera preview. I've also created another custom view class called DrawOnTop which just inherits directly from View, and I use this for drawing text and other items on top of the preview. Each view class works fine on its own, but when I load both views into the activity, the CameraPreview always dominates and none of the objects or text from the DrawOnTop class appear on top of the camera preview. Because I'm using two custom view classes, I'm not bothering to

Run SurfaceView off UI Thread

。_饼干妹妹 提交于 2019-12-02 03:16:05
My surfraceview is where the majority of my application is and I would like to reduce its lag, thus I have been told to take it off the UI Thread. Is it possible to run a SurfaceView in an AsyncTask? While it is possible to draw into a SurfaceView from an AsyncTask it is not recommended. AsyncTasks can run in a serial queue so you would likely block other tasks. Instead just use a Thread. The SDK contains a sample app called LunarLander which shows how to do this. 来源: https://stackoverflow.com/questions/15489571/run-surfaceview-off-ui-thread