2016-04-13 7 views
1

android app Screenshot bestimmte Layout, ich habe ein Problem, nach screenshoting, Bild schwarz Ausnahme Bilder, die auf dem Layoutandroid app Screenshot definitives Layout

dies meinen Code

{ 

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; 

} 

echte Screenshots :

enter image description here

mein Code des Screenshot:

enter image description here

Antwort

0

versuchen diesen Code:

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

ich nur "screenshotlayout" Layout Screenshot wollen.

<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> 
Verwandte Themen