This question has already been asked here, but it has no solution.
I have a WebView. I want to set minimum height to the WebView using minHeight attribute, but it doesn't work. The same attribute works for Button.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.anshul.webview.WebActivity">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="400dp"></WebView>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:minHeight="150dp"
android:text="This is a Button. It's minHeight is set to 150 dp and it works !!"/>
Clearly from the below image, the WebView is not supporting the minHeight attribute. Does anybody knows a solution for this problem?


First, let's understand how other view's use
android:minHeightattribute. Let's takeSpinnerfor example. InAbsSpinner#onMeasure()code we see following chunk of code:So,
getSuggestedMinimumHeight()should be regarded when computing preferred height.Now, let's see how
WebViewis being measured.WebView#onMeasure()delegates the job toWebViewChromium#onMeasure()WebViewChromium#onMeasure()delegates the job toAwContents#onMeasure()AwContents#onMeasure()delegates the job toAwLayoutSizer#onMeasureAwLayoutSizeris the last component that is responsible for measuringWebViewand we can clearly see, that itsonMeasure()does not respectgetSuggestedMinimumHeight()value.I'm not sure whether this is an intended behavior or no. Nevertheless, I cannot find enough seams to somehow affect that measurement process. Here's the chuck of code in
WebViewclass, where the object that eventually would returnWebViewChromium(the first step in abovementioned order) is initialized.As you can see, this is not something that can be easily customized/changed.