[英]capture screen shot programmatically in android
我有gridview並顯示圖像。 每次單擊圖像都會基於相同位置將列表活動顯示為對話框。 當我單擊列表活動上的后退按鈕捕獲屏幕時。 我能怎么做?
在這里,此示例可以工作,但不能將列表活動捕獲為對話框活動。 感謝高級
View v1 =getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bm = v1.getDrawingCache();
BitmapDrawable bitmapDrawable = new BitmapDrawable(bm);
holder.cardBack.setBackgroundDrawable(bitmapDrawable);
// holder.cardBack.setBackgroundResource(R.drawable.a);
holder.rootLayout.startAnimation(flipAnimation);
嘗試此操作,調用此方法,傳入要截屏的最外面的ViewGroup:
public Bitmap screenShot(View view) {
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(),
view.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
view.draw(canvas);
return bitmap;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.