2016-04-13 46 views
1

android app ekran görüntüsü kesin düzen, ben sorun, screenshoting sonra, görüntü düzeniandroid app ekran görüntüsü kesin düzeni

bu benim kod

{ 

Bitmap screenshot =getscreenshot((LinearLayout)findViewById(R.id.question_main)); 

String bitmapPath = MediaStore.Images.Media.insertImage(getContentResolver(), screenshot, "title", null); 

Uri bitmapUri = Uri.parse(bitmapPath); 

Intent sendIntent = new Intent(Intent.ACTION_SEND); 

sendIntent.setType("image/*"); 

sendIntent.putExtra(Intent.EXTRA_STREAM, bitmapUri); 

startActivity(Intent.createChooser(sendIntent, "Share screenshot")); 

}  


private Bitmap getscreenshot(View view) { 

    View v = view; 

    v.setDrawingCacheEnabled(true); 

    Bitmap bitmap = Bitmap.createBitmap(v.getDrawingCache()); 

    return bitmap; 

} 

gerçek ekran görüntüsü siyah istisna görüntüleri olduğunu var :

enter image description here

benim kodun ekran görüntüsü:

enter image description here

cevap

0

bu kodu deneyin: Ben sadece "screenshotlayout" düzen ekran görüntüsü istiyorum

private Bitmap getscreenshot() { 

    SimpleDateFormat date= new SimpleDateFormat("yyyy-MM-dd_hh:mm:ss").format(new Date()); 
     try { 

      String mPath = Environment.getExternalStorageDirectory().toString() + "/" + date+ ".jpg"; 

      // create bitmap screen capture 
      View v1 = getWindow().getDecorView().getRootView(); 
      v1.setDrawingCacheEnabled(true); 
      Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache()); 
      v1.setDrawingCacheEnabled(false); 

      File imageFile = new File(mPath); 

      FileOutputStream outputStream = new FileOutputStream(imageFile); 
      int quality = 100; 
      bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream); 
      outputStream.flush(); 
      outputStream.close(); 

      return bitmap; 
     } catch (Throwable e) { 

      e.printStackTrace(); 
     } 
    return null; 
} 
+0

http://stackoverflow.com/questions/36595095/android-app-screenshot-definite-layout/36600690#36600690 – Tarlan

0

.

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/mylayout"> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/sual_imagebox"/> 
     <LinearLayout 
      android:orientation="horizontal" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:id="@+id/screenshotlayout"> 
      <io.github.kexanie.library.MathView 
       android:id="@+id/sual" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       auto:text="text" 
       auto:engine="MathJax" 
       android:layout_below="@+id/bookmark"> 
      </io.github.kexanie.library.MathView> 
     </LinearLayout> 
    </RelativeLayout>