Android Photo Album Application

Below is an example, on how to develop a photo Album on Android

Activity file


import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.*;
import android.widget.FrameLayout;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {
    int count = 1;
    FrameLayout frame;
    ImageView imageview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        frame = (FrameLayout) findViewById(R.id.framelayout);
    }

    public void btn2click(View v) {

        imageview = (ImageView) frame.findViewWithTag(String.valueOf(count));
        imageview.setVisibility(View.INVISIBLE);
        count++;
        if (count > 6)
            count = 1;

        // Show next image
        imageview = (ImageView) frame.findViewWithTag(String.valueOf(count));
        imageview.setVisibility(View.VISIBLE);
    }

    public void btn1click(View v) {
        imageview = (ImageView) frame.findViewWithTag(String.valueOf(count));
        imageview.setVisibility(View.INVISIBLE);

        count--;
        if (count < 1)
            count = 6;

        imageview = (ImageView) frame.findViewWithTag(String.valueOf(count));
        imageview.setVisibility(View.VISIBLE);

    }
}

XML Layout file

<?xml version="1.0" encoding="utf-8"?>
<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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.bikash.imageviewexcelgyan.MainActivity">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:id="@+id/framelayout">

        <ImageView
            android:src="@drawable/image"
            android:layout_width="match_parent"
            android:layout_height="373dp"
            android:id="@+id/imageView"
            android:layout_gravity="center_horizontal|top"
            android:tag="1"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Next"
            android:id="@+id/btn2"
            android:layout_gravity="right|bottom"
            android:onClick="btn2click" />

        <ImageView
            android:src="@drawable/img"
            android:layout_width="match_parent"
            android:layout_height="373dp"
            android:id="@+id/imageView2"
            android:layout_gravity="center_horizontal|top"
            android:tag="2"
            android:visibility="invisible"/>

        <ImageView
            android:src="@drawable/imagec"
            android:layout_width="match_parent"
            android:layout_height="373dp"
            android:id="@+id/imageView3"
            android:layout_gravity="center_horizontal|top"
            android:tag="3"
            android:visibility="invisible"/>

        <ImageView
            android:src="@drawable/imaged"
            android:layout_width="match_parent"
            android:layout_height="373dp"
            android:id="@+id/imageView4"
            android:layout_gravity="center_horizontal|top"
            android:tag="4"
            android:visibility="invisible"/>

        <ImageView
            android:src="@drawable/imagee"
            android:layout_width="match_parent"
            android:layout_height="373dp"
            android:id="@+id/imageView5"
            android:layout_gravity="center_horizontal|top"
            android:tag="5"
            android:visibility="invisible"/>

        <ImageView
            android:src="@drawable/imagef"
            android:layout_width="fill_parent"
            android:layout_height="373dp"
            android:id="@+id/imageView6"
            android:layout_gravity="center_horizontal|top"
            android:tag="6"
            android:visibility="invisible"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Previous"
            android:id="@+id/btn1"
            android:layout_gravity="left|bottom"
            android:onClick="btn1click"/>

    </FrameLayout>
</RelativeLayout>

ImageViewAlbum
Android Photo Album App Download(on Android Studio)

Below are the screen shots, of the app

Android Simple Photo Album
Android Photo Album

Android Photo Album
Android Photo Album

You may also like to read:
permission in androidmanifest file
calculator app in android
Android difference between px and sp

This App is contributed by, Bikash Paul