我的应用使用webView。但是,它无法预览相机,因为webView覆盖在Android应用上的相机上。它显示白色/空白屏幕,但我可以拍照。
PS。 webView是CordovaWebView,Camera使用FrameLayout。
cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
//create or update the layout params for the container view
FrameLayout containerView = (FrameLayout)cordova.getActivity().findViewById(containerViewId);
if(containerView == null){
containerView = new FrameLayout(cordova.getActivity().getApplicationContext());
containerView.setId(containerViewId);
FrameLayout.LayoutParams containerLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
cordova.getActivity().addContentView(containerView, containerLayoutParams);
}
//display camera bellow the webview
if(toBack){
webView.getView().setBackgroundColor(0x00000000);
((ViewGroup)webView.getView()).bringToFront();
}else{
//set camera back to front
containerView.setAlpha(opacity);
containerView.bringToFront();
}
//add the fragment to the container
FragmentManager fragmentManager = cordova.getActivity().getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(containerView.getId(), fragment);
fragmentTransaction.commit();
cb.success("Camera started");
}
});