Size and position of GLSurfaceView
android, opengl-es, opengl-es-2.0
Solution
I want to place it in the center of the screen
You need to set gravity to the parent element like `Gravity.CENTER`. For example if it's `LinearLayout` then call `linearLayout.setGravity(Gravity.CENTER)`.
Set width and hight to exact phicical dimmension for example 20mm x 20mm
To calculate size from mm to pixels use:
float mmInPx = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_MM, 20,
getResources().getDisplayMetrics());
And to set size for GLSurfaceView use LayoutParams:
ViewGroup.LayoutParams layoutParams=glSurfaceView.getLayoutParams();
layoutParams.width=mmInPx;
layoutParams.height=mmInPx;
glSurfaceView.setLayoutParams(layoutParams);
Problem
Actually I have project in which I'm using GLSurfaceView. At this moment this component is placed as main control on whole screen. In this configuration I'm able proper handling drawing functionality. In next step I want to change size and position of GLSurfaceView. I want to place it in the center of the screen and set width and hight to exact phicical dimmension for example 20mm x 20mm. Do you have any advices or hints how should I start to introduce this kind of changes to GLSurfaceView?