左侧的这张图片显示了单击任何按钮之前的应用程序。我已经使用 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;
}