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;
}
}
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>
相关文章推荐
- Android webview旋转屏幕导致页面重新加载问题解决办法
- android 带fragment的Viewpager旋转屏幕时异常退出
- 【Android】常见异常 —— android.view.WindowLeaked 分析以及解决办法
- android异常之形如:android.view.InflateException: Binary XML file line #165: Error inflating class的解决办法
- Android旋转屏幕后国际化语言失效的解决办法
- 1.Android常见异常:android.view.WindowLeaked 分析以及解决办法
- 【Android】常见异常 —— android.view.WindowLeaked 分析以及解决办法
- android 聊天中 textview的气泡内容过多不换行导致出屏幕的解决办法
- 子线程更新UI会发生android.view.ViewRoot$CalledFromWrongThreadException异常的解决方法 .
- 子线程更新UI会发生android.view.ViewRoot$CalledFromWrongThreadException异常的解决方法 .
- [android]在eclipse中项目经常出现异常解决办法
- android开发 java.net.UnknownHostException:URL 异常解决办法
- android 自定义view 不执行 ondraw的解决办法
- 彻底解决 Canvas 引起的 java.lang.unsupported operation exception, android.view.GLES20Canvas.clipPath(GLES20Canvas异常
- Android.View.InflateException: Binary XML File Line #异常的解决
- Android 使用Webview无法播放视频问题的解决办法
- ANDROID解决屏幕旋转而导致重启ACTIVITY
- android.view.WindowLeaked异常解决方法
- Android NetworkOnMainThreadException异常解决办法
- android WebView使用cmwap无法联网解决办法