2016-08-20 5 views
1

私は自分のアクティビティでスクロールビューを使用しています。アクティビティ画面全体を共有したいのですが、それを行うことはできません。画面全体ではありません。完全な活動のスクリーンショットを撮ることができます。私はこれを試しましたが、アクティビティの可視部分だけを共有しています。 .Plzは私を助けます。ありがとうAndroidのアクティビティ画面の全体像をキャプチャする方法

スクリーンショットを撮影し保存
ShareImageView.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      // TODO Auto-generated method stub 

      //View v1 = getWindow().getDecorView(); 

       View v1 = findViewById(android.R.id.content); 

      v1.setDrawingCacheEnabled(true); 
      myBitmap = v1.getDrawingCache(); 
      saveBitmap(myBitmap); 


     } 

    }); 

::

public void saveBitmap(Bitmap bitmap) { 
    String filePath = Environment.getExternalStorageDirectory() 
    + File.separator + "Pictures/screencapture.png"; 
    File imagePath = new File(filePath); 
    FileOutputStream fos; 
    try { 
    fos = new FileOutputStream(imagePath); 
    bitmap.compress(CompressFormat.PNG, 100, fos); 
    fos.flush(); 
    fos.close(); 
    share(filePath); 
    } catch (FileNotFoundException e) { 
    Log.e("exception1", e.getMessage(), e); 
    } catch (IOException e) { 
    Log.e("exception2", e.getMessage(), e); 
    } 
    } 

答えて

0
try this: 

    public static Bitmap loadBitmapFromView(View v, int width, int height) { 
Bitmap b = Bitmap.createBitmap(width , height, Bitmap.Config.ARGB_8888);     
Canvas c = new Canvas(b); 
v.layout(0, 0, v.getLayoutParams().width, v.getLayoutParams().height); 
v.draw(c); 
return b; 

}我々は画面の高さと幅を渡す必要があり、画面の画面サイズにmethod.dependingで使用され、高さと幅と混同

+0

アム。@ Anantham –

+0

view.getWidth ()とview.getHeight @ Gauravsingh – YUVRAJ

+0

が動作していますが、それでも可視領域全体のスナップショットを取っているわけではありません。画面全体をキャプチャする他の方法@Anantham –

関連する問題