Android:Webview不会在轮换时调整大小(ICS)

时间:2012-06-06 07:35:58

标签: android android-webview screen-rotation

我的布局中有一个简单的WebView,具有以下设置

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rootView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/baserepeat"
    android:gravity="top|center_horizontal"
    android:orientation="vertical"
    android:paddingBottom="20dp"
    android:paddingLeft="20dp"
    android:paddingRight="20dp" >
 <WebView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/productDetailContentWebview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:background="@drawable/baserepeat" />
//other items...

在我的清单中,我将包含活动设置为

    <activity
        android:name=".Products.ProductDetailActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:screenOrientation="sensor"
        android:theme="@style/Theme.CPS" >
    </activity>

我的Webview在设备上填充了一个简单的HTML文件,效果很好。问题在于,当我将设备从纵向旋转到平面时,webview变得更高,在我的布局中进一步向下推动它下面的任何东西。内容量不会更改 - 它全部在OnCreate()中设置。

我正在使用Webview使用它自己的特殊样式表来呈现内容,并且它必须保留在ScrollView中。

如果需要,我可以提供更多信息:)

2 个答案:

答案 0 :(得分:4)

在使用2.3 / 4.0时我遇到了类似的问题......

我尝试了几件事,但帮助我摆脱核心问题的解决方案是:

screenSize 中的android:configChanges删除AndroidManifest.xml

希望它有所帮助!!!

答案 1 :(得分:0)

尝试在FrameLayout中包含您的网页视图。

<LinearLayout>
   <FrameLayout>  
   <WebView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/productDetailContentWebview"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:background="@drawable/baserepeat" />
   </FrameLayout>
相关问题