问题
I have a WebView
inside the ScrollView
.
The content of WebView
dyanamically changes when it displays different html page.
I have the following issue:
For example I have A.html
, and B.html
. The content of B.html
is larger than A.html
, so the page is longer.
When WebView
load B.html
, the ScrollView stretches its size to enable itself scroll for B.html, then if I go back to A.html
, ScrollView doesn't resize itself. (The scroll area is exceed the content of A.html
)

What I want to have, is dynamic change the scroll area of scroll view to fit the webview's content.
回答1:
That's not good idea to place WebView inside of ScrollView. WebView is smart enough to show scrollbars by itself.
回答2:
Try using android:fillViewport
in scroll view..!!
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroller"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
回答3:
After Orientation screen will resize, it works but bad in performance, not a very good solution
setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE );
setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_SENSOR );
回答4:
Don't put a WebView
inside of a ScrollView
.
来源:https://stackoverflow.com/questions/3509158/scroll-view-doesnt-resize-when-the-content-of-child-view-changes