1

私のアプリケーションでは、html ページを表示するために webview を使用しています。HTML ページには YouTube ビデオが含まれています。縦向きモードでは正常にロードされ、動作していますが、向きが横向きモードに変わると、ページが再度ロード (再作成) され、HTML ページのビデオが半分のサイズでしか表示されません。マニフェスト ファイルで android:configChanges="orientation" を使用しましたが、動作しません...また、向きが変わってもビデオは続行する必要があります

これが私のコードです...、

         webb=(WebView)findViewById(R.id.weeeb1);
                 webb.getSettings().setJavaScriptEnabled(true);
                    webb.setWebChromeClient(new WebChromeClient() {
                        public void onProgressChanged(WebView view, int progress)
                        {}
                    });

                    webb.setWebViewClient(new WebViewClient() {
                        @Override
                        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
                        {
                            // Handle the error
                        }

                        @Override
                        public boolean shouldOverrideUrlLoading(WebView view, String url)
                        {
                            view.loadUrl(url);
                            return true;
                        }
                    });
                    webb.getSettings().setPluginsEnabled(true);
                    //webb.setInitialScale(12);
                    webb.getSettings().setLoadWithOverviewMode(true);
                    webb.getSettings().setUseWideViewPort(true);
                    webb.setPadding(0,0,0,0); 
                    webb.loadUrl("file:///android_asset/index1.html");

Portrait mode

    <ScrollView android:id="@+id/row33"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/titletext"
          android:fillViewport="false"
          android:scrollbars="none"
          android:layout_weight="1"
          >
        <LinearLayout
          android:id="@+id/row35"
          android:layout_width="fill_parent"
          android:layout_height="600dp"
          android:layout_below="@+id/row33"
          android:layout_margin="8dp" 
          android:orientation="vertical" 
          android:layout_weight="1"
          >
    <LinearLayout
          android:id="@+id/row34"
          android:layout_width="fill_parent"
          android:layout_height="260dp"
          android:layout_below="@+id/row33"
          android:layout_marginLeft="6px"
          android:layout_marginRight="17px"
          android:orientation="horizontal" 
          android:layout_weight="1"
          android:background="#1C2F69"
          >


        <ImageView
            android:id="@+id/gimage1"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:layout_marginTop="10px"
            android:layout_marginLeft="30px"
            android:layout_marginRight="10px"
            android:layout_marginBottom="10px"
            android:background="@drawable/natureimage4"
            />

        <ImageView
            android:id="@+id/gimage2"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:layout_marginTop="10px"
            android:layout_marginLeft="10px"
            android:layout_marginRight="30px"
            android:layout_marginBottom="10px"
            android:background="@drawable/natureimage5"
            />

     </LinearLayout>
      <WebView 
         android:id="@+id/weeeb1" 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content" 
          android:layout_marginLeft="6px"
          android:layout_marginRight="17px"
          android:layout_marginTop="5px"
          android:layout_marginBottom="29dp"
         android:layout_below="@+id/row35"
          android:layout_weight="1"
         />
         </LinearLayout>
     </ScrollView>


Landscape mode

<ScrollView android:id="@+id/row33"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_below="@+id/titlemain"
      android:fillViewport="false"
      android:scrollbars="none"
      android:layout_weight="1">
    <LinearLayout
      android:id="@+id/row35"
      android:layout_width="fill_parent"
      android:layout_height="600dp"
      android:layout_below="@+id/row33"
      android:layout_marginLeft="190dp" 
      android:layout_marginRight="190dp"
      android:layout_marginTop="5dp"
      android:orientation="vertical" 
      android:layout_weight="1">
<LinearLayout

          android:id="@+id/row34"
          android:layout_width="fill_parent"
          android:layout_height="200dp"
          android:layout_below="@+id/row33"
          android:orientation="horizontal" 
          android:layout_weight="1"
          android:background="#1C2F69">


        <ImageView
            android:id="@+id/gimage1"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:layout_marginTop="10px"
            android:layout_marginLeft="35px"
            android:layout_marginRight="25px"
            android:layout_marginBottom="10px"
            android:background="@drawable/natureimage4" />

        <ImageView
            android:id="@+id/gimage2"
            android:layout_width="0dp"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            android:layout_marginTop="10px"
            android:layout_marginLeft="25px"
            android:layout_marginRight="35px"
            android:layout_marginBottom="10px"
            android:background="@drawable/natureimage5" />

     </LinearLayout>
      <WebView 
         android:id="@+id/weeeb1" 
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_marginBottom="9dp"
         android:layout_below="@+id/row35"
         android:layout_weight="1" />
         </LinearLayout>
     </ScrollView>


Please suggest me the solution....
4

2 に答える 2

1

1 つの解決策は、回転を避けることです。これを追加して、マニフェストでのみ縦向きのアクティビティを修正します。

android:screenOrientation="portrait"
于 2012-12-04T11:56:10.320 に答える