捕获特定布局屏幕截图或将特定布局保存在不同的 Activity 图像视图中
Capture a particular layout Screenshot or save a particular layout in a different Activity Imageview
我想捕获或保存特定布局并在另一个布局 Imageview 中显示
我用三个 ImageView 保存了一个 RelativeLayout。
在这些 ImageView 中,我设置了三个来自相机或图库的不同图像。
在我设置它们之后,我希望这个 RelativeLayout 显示在另一个 Activity 的 Imageview 中。
据我所知,没有任何简单的方法可以将布局传递给 android 中的另一个 activity。
您可以做的是将图像转换为位图,然后通过意图将位图发送到另一个 activity,因为位图实现了 Parcelable。
例如
intent.putExtra("data", bitmap)
试试这个。
RelativeLayout relative= (RelativeLayout) findViewById(R.id.allview);
if (tabLayout != null) {
Bitmap image = Bitmap.createBitmap(tabLayout.getWidth(),
tabLayout.getHeight(), Config.ARGB_8888);
Canvas b = new Canvas(image);
relative.draw(b);
}
捕获您在某些事件中的布局的屏幕截图。使用下面的代码。并使用 intent 将其发送到下一个 activity.
yourlayout.setDrawingCacheEnabled(true);
Bitmap myBitmap = yourlayout.getDrawingCache();
Intent intent=new Intent(this,NextActivity.class);
intent.putExtra("data", myBitmap )
startActivity(intent);
我想捕获或保存特定布局并在另一个布局 Imageview 中显示
我用三个 ImageView 保存了一个 RelativeLayout。
在这些 ImageView 中,我设置了三个来自相机或图库的不同图像。
在我设置它们之后,我希望这个 RelativeLayout 显示在另一个 Activity 的 Imageview 中。
据我所知,没有任何简单的方法可以将布局传递给 android 中的另一个 activity。 您可以做的是将图像转换为位图,然后通过意图将位图发送到另一个 activity,因为位图实现了 Parcelable。
例如
intent.putExtra("data", bitmap)
试试这个。
RelativeLayout relative= (RelativeLayout) findViewById(R.id.allview);
if (tabLayout != null) {
Bitmap image = Bitmap.createBitmap(tabLayout.getWidth(),
tabLayout.getHeight(), Config.ARGB_8888);
Canvas b = new Canvas(image);
relative.draw(b);
}
捕获您在某些事件中的布局的屏幕截图。使用下面的代码。并使用 intent 将其发送到下一个 activity.
yourlayout.setDrawingCacheEnabled(true);
Bitmap myBitmap = yourlayout.getDrawingCache();
Intent intent=new Intent(this,NextActivity.class);
intent.putExtra("data", myBitmap )
startActivity(intent);