glsurfaceview의 높이를 맞춤 높이로 설정하고 싶습니다. 너비가 높이와 같아야합니다. android : layout_width = "fill_parent". width = height = width_of_the_screen을 어떻게합니까?안드로이드 setHeight of glsurfaceview
덕분에 많은
glsurfaceview의 높이를 맞춤 높이로 설정하고 싶습니다. 너비가 높이와 같아야합니다. android : layout_width = "fill_parent". width = height = width_of_the_screen을 어떻게합니까?안드로이드 setHeight of glsurfaceview
덕분에 많은
당신은 프로그래밍 방식으로, 그렇지 않으면 measuredWidth
그냥 0을 반환합니다, 문제는이 뷰가 처음으로 그려진 된 후에 수행해야합니다입니다 view.getLayoutParams().height = view.getMeasuredWidth();
을 사용하여 높이를 설정할 수 있습니다. (당신이 openGL을 사용한다고 가정하면) 렌더러 클래스의 onDraw
이 호출 될 때까지는 확실히 화면에 그려집니다. 그러나 GL 스레드 (그 호출 onDraw
)와 뷰의 너비/높이 등을 변경할 수있는 유일한 (UI) 스레드 인 메시지 사이에 메시지를 전달해야합니다.
상기 수신 된 onMeasure 폭 setMeasuredDimension 두 파라미터 세트는 아래와 같이
class TouchSurfaceView extends GLSurfaceView {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = View.MeasureSpec.getSize(widthMeasureSpec);
this.setMeasuredDimension(width, width);
}
...
레이아웃으로 다음과 같이
...
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_gravity="top"
>
<se.company.test.TouchSurfaceView android:id="@+id/glSurface"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
...