I have a layout below where i have a linear layout with gravity as center to make the child center aligned.I want to add a webview programatically and loading the youtube vi
Well, I may be too late. But, what I do :
AndroidManifest.xml
android:configChanges="orientation"
WebViewContainerActivity.java
@Override
public void onConfigurationChanged(Configuration newConfig) {
/* WebView mainView is declared globally */
ConstraintLayout lana = findViewById(R.id.main);
lana.removeView(mainView);
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int screenWidth = displaymetrics.widthPixels;
int screenHeight = displaymetrics.heightPixels;
lana.addView(mainView, 0,
new ConstraintLayout.LayoutParams(
screenWidth,
screenHeight));
super.onConfigurationChanged(newConfig);
}
It does it's work efficiently, and I must use this because I don't understand HTML.