Development issue/problem:

I built an array that is essentially a HorizontalScrollView within a ScrollView. I have asked the user to change the fields.

Now I want to save the painting on the screen, as jpg, png, pdf or other.

The problem is that the table is almost always larger than the screen.

Is it possible to take a screenshot of the entire ScrollView presentation? If not, what do you think can be done?

How can I solve this problem?

Solution 1:

Actually, I found the answer:

public static bitmap loadBitmapFromView(View v) {
Bitmap b = Bitmap.createBitmap(v.getWidth() , v.getHeight(), Bitmap.Config.ARGB_8888) ;
Canvas c = new Canvas(b) ;
v.draw(c) ;
return b ;
}.

Solution 2:

ScrollView iv = (ScrollView) findViewById(R.id.scrollView);
Bitmap bitmap = Bitmap.createBitmap(
iv.getChildAt(0).getWidth(),
iv.getChildAt(0).getHeight(),
Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(bitmap);
iv.getChildAt(0).draw(c) ;

// Do what you want with your
saveBitmap (bitmap) ;

Solution 3:

The use of the @software answer is a problem in my case where my opinion has been redesigned and has become completely white. There is an easier solution to get screenshots where you don’t even have to specify width and height as parameters.
Use the drawing cache.

public Bitmap loadBitmapFromView(View v) {
bitmap;
v.setDrawingCacheEnabled(true);
bitmap = Bitmap.createBitmap(v.getDrawingCache());
v.setDrawingCacheEnabled(false);
return bitmap;
}.

Solution 4:

It is not possible to take a screenshot of content that is not displayed on the screen (e.g. off-screen parts of ScrollView). However, you can take multiple screenshots by scrolling through the content between the shots and then merging the images. Here is a tool that can automate this for you: https://github.com/PGSSoft/scrollscreenshot.

Disclaimer : I am the author of this instrument, it was published by my employer. Registrations for the competition are welcome.

Solution No 5:

Download the source code here (screenshot of scrolling in the Android software)

Active_main.xml

MainActivity.xml

package.screenshot;
import android.manifest;
import android.content.intention;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.bundle;
import android.support.v4.app.ActivityCompatible;
import android.Support.v4.Content.ContextCompatible;
import android.app.activityCompatible;
import android.util.log;
import android.view.view;
import android.widget.button;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.Toast ;

importing java.io.File ;
importing java.io.FileNotFoundException ;
importing java.io.FileOutputStream ;
importing java.io.IOException;

The MainActivity public class expands AppCompatActivity {

Button btn_screenshot;
scrollView scrollView;
LinearLayout ll_linear;
public static int REQUEST_PERMISSIONS = 1;
boolean boolean_permission;
boolean_save ;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
init();
fn_permission();
}.

private void init() {
btn_screenshot = findViewById(R.id.btn_screenshot) ;
scrollView = findViewById(R.id.scrollView) ;
ll_linear = findViewById(R.id.ll_linear) ;

btn_screenshot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (boolean_save) {
Intent intent = new Intent(getApplicationContext(), Screenshot.class) ;
startActivity(intention) ;

} otherwise {
if (boolean_permission) {
Bitmapbitmap1 = loadBitmapFromView(ll_linear, ll_linear.getWidth(), ll_linear.getHeight());
saveBitmap(bitmap1);
} otherwise {

}
}

}
});
}

public void saveBitmap(bitmap bitmap) {
File imagePath = new file(/sdcard/screenshotdemo.jpg);
FileOutputStream phosph;
try {
phosph = new FileOutputStream(imagePath);
bitmap.compress(Bitmap).CompressFormat.PNG, 100, phosph) ;
phosph.flush() ;
phosph.close() ;
Toast.makeText(getApplicationContext(), imagePath.getAbsolutePath() + , Toast.LENGTH_SHORT).show() ;
boolean_save = true ;

btn_screenshot.setText(check image) ;

Log.e (ImageSave, Save Image);
} capture (IOException e) {
Log.e(GREC, e.getMessage(), e);
}
}.

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.draw(c) ;

back b;
}

private void fn_permission() {
if ((ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.READ_EXTERNAL_STORAGE)) PackageManager.WRITE_EXTERNAL_STORAGE) |
(ContextCompatible.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.GUARANTIVE_PERMISSION) {
if ((! ActivityCompatible.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE))))) {
ActivityCompatible.requestPermissions.this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
REQUEST_PERMISSIONS);
}.

if ((!ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE))))) {
ActivityCompatible.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
REQUEST_PERMISSIONS);
}
} otherwise {
boolean_permission = true;
}
}

@Public Void Check
onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults) ;

if (requestCode == REQUEST_PERMISSIONS) {
if (grantResults.length > 0 && grantResults [0] == PackageManager.PERMISSION_WARRANTY) {
boolean_permission = true ;

} otherwise {
Toast.makeText(getApplicationContext(), Give permission, Toast.LENGTH_LONG).show() ;

}
}
}
}

Thank you so much!

Solution No 6:

You can switch the display to a new canvas instance built on a bitmap object.

Try using

Bitmap b = Bitmap.createBitmap(targetView.getWidth(),
targetView.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
targetView.draw(c);
BitmapDrawable d = new BitmapDrawable(getResources(), b);
canvasView.setBackgroundDrawable(d); “Documentation

Actually, he did the work for me.

Solution No 7:

this job for me, I hope it will help you, too.

public static bitmap getBitmapByView(ScrollView scrollView) {
int h = 0 ;
Bitmap bitmap = null ;
// get current scroll height
for (int i = 0 ; i

Solution No 8:

Maybe you can use the display cache, but I’m not sure if it contains the whole display or just what’s displayed on the screen.

I suggest you look up similar questions on StackOverflow, they’ve probably been asked before.

Solution No 9:

Try it and I’ll like it.

TableLayout tabLayout = (TableLayout) findViewById(R.id.allview) ;

if (tabLayout != null) {

Bitmap.createBitmap(tabLayout.getWidth(),
tabLayout.getHeight(), Config.ARGB_8888);
Canvas b = new Canvas(image) ;

tabLayout.draw(b);
}

Solution No 10:

//Stable click listener

share = (button)findViewById(R.id.share) ;
share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Bitmap bitmap = takeScreenshot() ;
saveBitmap(bitmap) ;

}
});

// then you have to create two methods

public Bitmap takeScreenshot() {
View rootView = findViewById(android.R.id.content).getRootView();
rootView.setDrawingCacheEnabled(true);
return rootView.getDrawingCache();
}.

public void saveBitmap(bitmap bitmap) {
FilePath = new file(Environment.getExternalStorageDirectory() + /screenshot.png);
FileOutputStream phosph;
try {
phosph = new FileOutputStream(imagePath);
bitmap.Compress(Bitmap.CompressFormat.PNG, 100, phosph);
phosph.flush();
phosph.close();
} catch (FileNotFoundException e) {
Log.e(GREC, e.getMessage(), e);
} catch (IOException e) {
Log.e(GREC, e.getMessage(), e);
}
}.

After adding this code to your application, starting the application and checking the local storage, you have taken a screenshot of the whole page.

Good luck!

screen capture (by google),chrome screenshot without extension,full page screenshot iphone,full page screen capture firefox,capture screen region chrome,how to take full page screenshot in android,how to screenshot whole page iphone,how to screenshot an entire webpage mac,screenshot on pc nimbus,internet explorer 11 screenshot whole page,scrolling screenshot mac,scrolling screenshot windows 10,camera logofull page screen capture,fireshot chrome,how to save screenshot as jpg windows 10,save print screen as jpeg automatically,screen clipping word,how to make a screenshot into a link,how to screenshot an email in gmail,paste print screen as image,how to crop a screenshot on mac,screen capture mac catalina,how to paste screenshot on mac,screenshot on mac not working,how to print on mac,how to screenshot on mac without keyboard,screen capture by goole,screen capture google docs,chrome developer tools screenshot entire page,screen capture,full page screen capture,android take screenshot of view programmatically,how to take screenshot of particular layout in android,screenshot entire webpage mac,take screenshot of surfaceview android,view screenshot android

You May Also Like

Root Samsung Galaxy A21s SM-A217F/M/N and Install TWRP Recovery

If you own a Samsung Galaxy A21s SM-A217F/M/N smartphone and want to…

6 WordPress Translation Plugins To Create Multi-Language Websites

Do you want to create a multilingual WordPress site with the best…

How to Add Sound Equalizer for Windows 10 in Few Steps (2021)

Facebook Twitter Pinterest Reddit Messenger WhatsApp If you’re here because you’re a…

Find out if 32 GB is enough for an iPad

4. January 2021 Kitiya Lovska Choosing the right iPad for your needs…