Search code examples
androidwebviewhorizontalscrollview

Contents stretching to fill HorizontalScrollView


I'm doing an inadvisable thing here, and I know it, but I have a webview nested in a horizontalscrollview. (I needed more scrolling control than webview provides.)

The layout looks like this:

<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webRel"
    android:layout_below="@+id/titlebar"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <WebView 
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webZ"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    />
</HorizontalScrollView>

And the results are as follows: My webview.

The webview isn't filling up the horizontalscrollview. The horizontalscrollview is filing the view, so I guess I could say the webview isn't filling the view even though I have both set to fill_parent. I would really, really like it if someone would help me figure out how to have the webview fill up the horizontalscrollview widthwise... because then I measure the height and use that measurement to paginate the text (which is then displayed in chunks widthwise which is why I chose horizontalscrollview.)

:D

(Alternatively, suggestions for a cleaner way to have smooth horizontal scrolling in a webview would also be helpful.)


Solution

  • The answer is: use android:fillViewPort. It'll have the contents of the scrollview stretch to fill the view.