1

このリンクをたどって、Webビューを完全にスクリーンショットしました。正常に動作します。しかし、私には問題があります。Webビューから取得したスクリーンホットには、画像の上下に空白が含まれていますか?どうすればこれを取り除くことができますか?教えてください。

これは、Webビューからキャプチャするために使用したコードです。適切に見ると、画像の下部と上部の両方に空白があります。

    public static String saveCapturedImageToSdCard() {


        Picture picture = WebViewActivity.sWebViewEx.capturePicture();
        Bitmap  b = Bitmap.createBitmap( picture.getWidth(),
        picture.getHeight(), Bitmap.Config.ARGB_8888);
        File file = null;
        Canvas c = new Canvas( b );

        picture.draw( c );
//        FileOutputStream fos = null;
        try {
            file = new File(Environment.getExternalStorageDirectory()+"/"+"temp.png");
            if(file != null && !file.exists())
                file.createNewFile();
            // write the bytes in file
            FileOutputStream fos = new FileOutputStream(file);
            fos = new FileOutputStream(file);
                if ( fos != null )
                {
                    b.compress(Bitmap.CompressFormat.PNG, 100, fos);

                    fos.close();
                }
            }
       catch( Exception e )
       {

       }
        return file.getPath().toString();
}

これは私がウェブビューから取得した画像です:

スクリーンショット画像

私のXMLは次のとおりです。

<WebView
        android:id="@+id/webview"
        android:layout_below="@id/linearlayout_topbuttons"
        android:layout_above="@id/gallery_webview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:overScrollMode="never"
        android:fitsSystemWindows="true"
        android:background="@android:color/transparent"
        android:layout_centerInParent="true"
        />
4

0 に答える 0