Reputation:
I'm trying to build an app with a webview which should go fullscreen when the orientation changes to landscape. I did the way with layout-land and main.xml where I just gave the WebView fill_parent and it was over all the other views. The problem with that was, that the WebView was lagging. I hope there is another way to do it. My WebView loads a URL which is created by a button in relation with what the user put into some spinners. So if the fullscreen webview needs a new activity I need to parse the URL. I hope you can help me. Thank you!
Upvotes: 1
Views: 1039
Reputation: 670
add this to your main Activity
@Override
public void onConfigurationChanged (Configuration config) {
super.onConfigurationChanged(config);
switch(config.orientation) {
case Configuration.ORIENTATION_LANDSCAPE:
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
ActivitiesCurrentContentView.requestLayout();
break;
case Configuration.ORIENTATION_PORTRAIT
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
ActivitiesCurrentContentView.requestLayout();
break;
}
}
Upvotes: 1