Skip to content

Instantly share code, notes, and snippets.

@kunmi
Created January 7, 2018 01:20
Show Gist options
  • Save kunmi/77a6c77c73e9eb7d87767fcf1d2c82e7 to your computer and use it in GitHub Desktop.
Save kunmi/77a6c77c73e9eb7d87767fcf1d2c82e7 to your computer and use it in GitHub Desktop.
kunmii.blogspot.com snippet for Building an Animated QR Scanner Viewfinder - Like Whatsapp web scanner view
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<SurfaceView
android:id="@+id/cameraView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="185dp"
android:background="@color/semitransparent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<View
android:id="@+id/left"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@color/semitransparent" />
<LinearLayout
android:id="@+id/scannerLayout"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_toEndOf="@+id/left"
android:layout_toLeftOf="@id/right"
android:layout_toRightOf="@id/left"
android:layout_toStartOf="@+id/right"
android:background="@drawable/ic_viewfinder"
android:orientation="horizontal">
<View
android:id="@+id/scannerBar"
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@color/colorPrimary" />
</LinearLayout>
<View
android:id="@+id/right"
android:layout_width="40dp"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="@color/semitransparent" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="185dp"
android:background="@color/semitransparent" />
</LinearLayout>
</FrameLayout>
@kunmi
Copy link
Author

kunmi commented Jan 7, 2018

kunmii.blogspot.com
snippet embedded in the blog post explaining how to build "an Animated QR Scanner Viewfinder" similar to Whatsapp web's QR scanner-view

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment