# Android开发中防止旋转屏幕时WebView重新加载

- Link: https://www.xuepaijie.com/html/skill/devops/1057.html
- Published: 2018-04-24T23:37:58+08:00
- Author: Admin

默认情况下当旋转屏幕时，WebView将重新加载整个页面。怎么解决旋转时屏幕会从loadUrl（）
方法重新加载原始URL的问题？

无需Java编码，在配置文件中这样配置：

    ```html;
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
    ```

举例：

    ```html;
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.Example.WebviewSample.webviewsample"
            android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>        
    </application>
    ```
