Android Camera2 API LooknFeel

Android camera2 api - Part 1

Part 1 of the how to use android camera2 api’s. Part one is about preparing the look & feel of the application.

Android Camera2 API LooknFeel – Part 1 of a new tutorial series on how to use the android camera 2 api’s. Part 1 focuses on the look & feel of the application, which is based on the recyclerview image gallery

Code available on github

You can clone the code from

https://github.com/mobapptuts/recyclerview_image_gallery.git Tag looknfeel

or else you can run this command

git clone --branch looknfeel https://github.com/mobapptuts/recyclerview_image_gallery.git 

Configure the layout files

activity_camara_intent.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".CamaraIntentActivity">

    <TextureView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/textureView"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Take Photo"
        android:id="@+id/photoButton"
        android:onClick="takePhoto"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <android.support.v7.widget.RecyclerView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/galleryRecyclerView"
        android:layout_above="@id/photoButton"
        />


</RelativeLayout>

gallery_images_relative_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageGalleryView"
        android:layout_margin="10dp"
        android:layout_alignParentTop="true" />

</RelativeLayout>

Change the RecyclerView’s orientation to horizontal

GridLayoutManager layoutManager = new GridLayoutManager(this, 1);
        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);

Run & Test & Debug

About The Author
-

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>