title: how to open camera with qr code scanner?
body: <p>I have an applicaton and on its main activity there is a button, clicking on which opens a fragment at the center of the screen.<br>
  I have working code which opens camera at center as explained but  I want that simple camera view to change into qr scanner.I now have added zxing library dependency. and how to make it work when opening camera? can't arrange code. (in oncreate view) .<br>
  Any help would be great please.</p>
  
  <pre><code>//method in scan.java
  @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
                               Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.fragment_scan, container, false);
  
          if(checkCameraHardware(getActivity().getApplicationContext())){
  zXingScannerView  = new ZXingScannerView(getActivity().getApplicationContext());
  
              //zXingScannerView.startCamera(); I tried something like this
  
              mCamera = Camera.open();
              mCamera.setDisplayOrientation(90);
              Camera.Parameters params = mCamera.getParameters();
             params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
              mCamera.setParameters(params);
              mPreview = new CameraPreview(this.getActivity(), mCamera);
  
  
              //container.addView(mPreview);---&gt;Remove this line
              //Add this line
  
              FrameLayout preview =(FrameLayout)view.findViewById(R.id.camera_preview);
              preview.addView(mPreview);
          }
          // Inflate the layout for this fragment
          return view;
      }
  </code></pre>
  
  <pre class="lang-html prettyprint-override"><code>//fragment_scan.xml
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
  
      tools:context="layout.scan"
      android:layout_centerInParent="true"
  android:layout_marginTop="@dimen/nav_header_height"
  android:layout_marginBottom="@dimen/fab_margin"
      android:layout_marginLeft="@dimen/fab_margin"
  
      &gt;
  &lt;FrameLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/camera_preview"
      &gt;
  
  
      &lt;/FrameLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>