Reputation: 251
I have created glsurfaceview
in xml file, I'd like to change X,Y of this glsurfaceView
when the button is pressed.
I have onSurfaceChanged()
method and there are x,y variables.
can I call this method for chane glsurfaceview
position?
if I can, how can I do it, or how can change position?
Upvotes: 0
Views: 1105
Reputation: 3014
I have onSurfaceChanged() method and there are x,y variables. can I call this method for chane glsurfaceview position?
No, you can't, because onSurfaceChanged (GL10 gl, int width, int height)
serves as an event. It is called by the OpenGL ES subsystem when your surface size has already changed. Therefore, it is for overriding and performing certain typical operations (as detailed here) when the size of your surface has already changed.
Since GLSurfaceView
is a SurfaceView
descendant and is part of the View
hierachy, you can use the usual positioning methods (such as setX()) to set its position (but don't forget about screen- and density-independence that you should ensure in your Android applications).
As a side note: I don't know your application architecture and details, but when there is a need to re-position a GLSurfaceView
, then usually there is an equivalent solution/workaround to the same problem that doesn't require repositioning.
Upvotes: 1