您的位置:首页 > 移动开发 > Android开发

Android GLSurfaceView在屏幕旋转后绘图区域异常的解决办法

2016-09-09 14:04 716 查看
添加代码

public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);

DisplayMetrics mDisplayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(mDisplayMetrics);
int W = mDisplayMetrics.widthPixels;
int H = mDisplayMetrics.heightPixels;

if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
imageSurfaceView.getLayoutParams().width = W;
imageSurfaceView.getLayoutParams().height = H;

}
else{
imageSurfaceView.getLayoutParams().width = W;
imageSurfaceView.getLayoutParams().height = H;
}
}

<activity
android:name="com.wztech.mobile.demo.MainActivity"
<span style="color:#ff0000;">android:configChanges="keyboardHidden|orientation|screenSize|screenLayout"</span>
android:launchMode="singleTask"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: