I have an android activity with a relative layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.transactions.detail.TransactionDetailActivity"
android:background="@drawable/background_gradient"
android:id="@+id/wrapperLayout" >
<!--CODE HERE-->
</RelativeLayout>
Programmatically (in Kotlin)
I add a WebView
to the layout
:
val wv = WebView(this);
wv.setInitialScale(1);
wv.settings.javaScriptEnabled = true;
wv.settings.loadWithOverviewMode = true;
wv.settings.useWideViewPort = true;
wv.setPadding(0, 0, 0, 0);
wv.layout(0, 0, 0, 0);
wv.setWebViewClient(WebViewClient(this));
val relativeLayout = findViewById<RelativeLayout>(R.id.wrapperLayout);
relativeLayout.addView(wv);
When I load some urls, it happens that the size of the webview changes.
The behaviour I want is this:
How can I fix the webview size to cover the screen?
Related answer: https://stackoverflow.com/a/9499811/1148281