左边的这张图片显示了点击任何按钮之前的应用程序。我使用了camera2 google github示例,使背景成为相机预览。右边的图片是我点击了takePicture按钮的时候。图片没有显示!屏幕截图和相机不能同时工作吗?另外我应该如何摆脱顶部出现的黑条?任何帮助,将不胜感激。也许在我拍摄截图之前锁定相机的焦点??
private void takePicture() {
if (picturePresent == false) {
edit_button.setVisibility(View.INVISIBLE);
pictureBitmap = getBitmapFromView();
edit_button.setVisibility(View.VISIBLE);
BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), pictureBitmap);
outer_backround.setBackground(bitmapDrawable);
picturePresent = true;
} else {
}
}
public Bitmap getBitmapFromView() {
View v1 = getActivity().getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
Bitmap resizedBitmap = Bitmap.createBitmap(bitmap,(int) outer_backround.getX(), (int) outer_backround.getY(), outer_backround.getWidth(), outer_backround.getHeight());
return bitmap;
}
答案 0 :(得分:1)