The photo Gallary app with source code ,how to build the simple gallary application ?my 14th app ? Nilesh Raut

 How to make an simple gallary application in andriod studio?  Mr.Nilesh Vishnu Raut
 





Me Mr,Nilesh Vishnu Raut , An andriod devloper at Xiaomi corporation .with certification .


Requirment:

1. Need minimum intel i7 processer of any genration
2.Need an big storage with ssd that will bost your andriod studio
3. Need photoshop and adobe illustrator for designing background and logo


you have to create an raw folder in your andriod studio and kept all th file their .which mean that you app can acsess his file easily . after putting all code in your andriod studio make sure that you have an best internet connectivity .you sould always use an broad brand . for an photo of an raw file is her go and check it:

photo gallary





Source code:


1) XML file (design section)


<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/back"
tools:context=".MainActivity">

<ImageView
android:id="@+id/pic0"
android:layout_width="261dp"
android:layout_height="406dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@raw/pic0" />

<ImageView
android:id="@+id/pic1"
android:layout_width="261dp"
android:layout_height="406dp"
android:alpha="0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@raw/pic1" />

<ImageView
android:id="@+id/pic2"
android:layout_width="261dp"
android:layout_height="406dp"
android:alpha="0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@raw/pic2" />

<ImageView
android:id="@+id/pic3"
android:layout_width="261dp"
android:layout_height="406dp"
android:alpha="0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@raw/pic3" />

<ImageView
android:id="@+id/pic4"
android:layout_width="261dp"
android:layout_height="406dp"
android:alpha="0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@raw/pic4" />

<ImageView
android:id="@+id/pic5"
android:layout_width="261dp"
android:layout_height="406dp"
android:alpha="0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@raw/pic5" />

<ImageView
android:id="@+id/pic6"
android:layout_width="261dp"
android:layout_height="406dp"
android:alpha="0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@raw/pic6" />


<ImageView
android:id="@+id/pic7"
android:layout_width="261dp"
android:layout_height="406dp"
android:alpha="0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@raw/pic7" />

<TextView
android:id="@+id/textView"
android:layout_width="217dp"
android:layout_height="47dp"
android:text="Your photo"
android:textColor="#770606"
android:textSize="30sp"
app:layout_constraintBottom_toTopOf="@+id/pic0"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<LinearLayout
android:layout_width="366dp"
android:layout_height="74dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pic0">

<ImageButton
android:id="@+id/prev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="prev"
app:srcCompat="@drawable/icon_prev" />

<ImageButton
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="next"
app:srcCompat="@drawable/ic_baseline_skip_next_24" />
</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

2) Manifest which is for your permission


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nilesh.photoframe">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.PhotoFrame">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Now main and last part 
3) Java main file( brain of app(backend))

package com.nilesh.photoframe;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
ImageButton prev, next;
ImageView pic;
TextView text;
int currimg =0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}

public void prev(View v) {
String idX = "pic" + currimg;
int x = this.getResources().getIdentifier(idX,"id",getPackageName());
pic =findViewById(x);
pic.setAlpha(0f);

currimg = (7+currimg-1)%7;
String idY = "pic" + currimg;
int y = this.getResources().getIdentifier(idY,"id",getPackageName());
pic =findViewById(y);
pic.setAlpha(1f);


}

public void next(View v) {
String idX = "pic" + currimg;
int x = this.getResources().getIdentifier(idX,"id",getPackageName());
pic =findViewById(x);
pic.setAlpha(0f);

currimg = (7+currimg+1)%7;
String idY = "pic" + currimg;
int y = this.getResources().getIdentifier(idY,"id",getPackageName());
pic =findViewById(y);
pic.setAlpha(1f);
}
}


this preview of an my app :
photo gallary







Post a Comment

0 Comments

Ad Code