2013-03-05 2 views
0

내 웹보기에서 현재 페이지의 스크린 샷을 찍으려고하지만 스크린 샷을 할 때 내가 원치 않는 액션 바를 찍고 있습니다. 나는 단지 웹보기를 얻으려고하고있다. 이것이 가능한가 ?Android 액션 바가없는 웹보기의 스크린 샷

개인 무효 goScreenShot() {

// Get device dimmensions 
    Display display = getWindowManager().getDefaultDisplay(); 
    Point size = new Point(); 
    display.getSize(size); 

// Get root view 
    View view = mWebView.getRootView(); 
    // Create the bitmap to use to draw the screenshot 
    final Bitmap bitmap = Bitmap.createBitmap(size.x, size.y, Bitmap.Config.ARGB_8888); 
    final Canvas canvas = new Canvas(bitmap); 

    // Get current theme to know which background to use 
    final Activity activity = this; 
    final Theme theme = activity.getTheme(); 
    final TypedArray ta = theme 
     .obtainStyledAttributes(new int[] { android.R.attr.windowBackground }); 
    final int res = ta.getResourceId(0, 0); 
    final Drawable background = activity.getResources().getDrawable(res); 

    // Draw background 
    background.draw(canvas); 

    // Draw views 
    view.draw(canvas); 

    // Save the screenshot to the file system 
    FileOutputStream fos = null; 
    try { 
     final File sddir = new File(SCREENSHOTS_LOCATIONS); 
     if (!sddir.exists()) { 
      sddir.mkdirs(); 
     } 
     //fos = new FileOutputStream(SCREENSHOTS_LOCATIONS 
      //  + System.currentTimeMillis() + ".jpg"); 

     fos = new FileOutputStream(SCREENSHOTS_LOCATIONS 
         + "Screenshot" + ".jpg"); 
     Log.d("screenshot location", SCREENSHOTS_LOCATIONS.toString()); 
     if (fos != null) { 
      if (!bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fos)) { 
       Log.d("ScreenShot", "Compress/Write failed"); 
      } 
      fos.flush(); 
      fos.close(); 

     } 

    } catch (FileNotFoundException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    startActivity(new Intent(WebViewActivity.this, ScreenViewer.class));  
} 

답변

2

당신은이에 대한 도면 캐시 속성을 사용할 수 있습니다. 이 같은

: 당신의 응답을

View main = findViewById(R.id.view); 
Bitmap screenshot; 
main.setDrawingCacheEnabled(true); 
screenshot = Bitmap.createBitmap(main.getDrawingCache()); 
main.setDrawingCacheEnabled(false); 
+0

감사합니다. 혹시 날 조금 더 밀어 주실 수 있으십니까? – cmhdev

+0

도와 주셔서 감사합니다! – cmhdev