Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to generate and save image of layout in android

LinearLayout content = findViewById(R.id.rlid);
content.setDrawingCacheEnabled(true);
Bitmap bitmap = content.getDrawingCache();
File file,f;                    
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) 
    {  
         file =new File(android.os.Environment.getExternalStorageDirectory(),"TTImages_cache");
         if(!file.exists())
        {
          file.mkdirs();

         } 
         f = new File(file.getAbsolutePath()+file.seperator+ "filename"+".png");
    }
  FileOutputStream ostream = new FileOutputStream(f);                                   
  bitmap.compress(CompressFormat.PNG, 10, ostream);
  ostream.close();

 } 
 catch (Exception e){
 e.printStackTrace();
}
Comment

PREVIOUS NEXT
Code Example
Java :: spigot deal damage 
Java :: android capture view and animation 
Java :: java.lang.IllegalStateException: Not scheduled yet 
Java :: android studio press button programmatically 
Java :: Java Shuffling Using shuffle() 
Java :: how to find all apps on android device using java 
Java :: final java 
Java :: seekbar thumb position 
Java :: bukkit shutdown 
Java :: action media scanner scan file android 30 deprecated 
Java :: turn on device location android programmatically 
Java :: import java.util.* 
Java :: Write a java program to print a number from the user 
Java :: discord jda await msg 
Java :: how to move get selected from jfxtreetableview javafx 
Java :: collapsingtoolbarlayout collapse listener 
Java :: java console readline null pointer exception 
Java :: Java Catching base and child exception classes 
Java :: Make device not run on emulator or rooted device 
Java :: interfaces in java 
Java :: why left+(right-left)/2 will not overflow? 
Java :: regex pattern for car plates 
Java :: 2 multiples 
Java :: castle stones java qn 
Java :: java equivalent of pythons getattr 
Java :: space between lines textview android 
Java :: editable column 
Java :: java no name array eg 
Java :: set background drawable programmatically android 
Java :: java boolean even number 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =