In this Android Tutorial On Gallery View we will learn how to show a static image gallery using images and buttons, the main ideology of this tutorial is to give a view of how the gallery can be made in a simple terms for beginners.

Gallery view is shown both in vertical and horizontal view, but the only difference is that layout file differs but same coding can be applicable for both the activity’s as almost all functionality is same but only view is changed accordingly.

 activity_main.xml

Adding two buttons to access two gallery views.

 

Creating MainActivity.java :

 

 

Now we will create gallery1 and gallery2 xml files accordingly you can observe the difference in layout adjustments.

 

Creating gallery1.xml :

 

Adding ten buttons and a imageview to display selected image.

 

Creating gallery2.xml :

 

 

Creating Gallery1.java :

 

Setting image to imageview as

 

 

Creating Gallery2.java :

Gallery2 is same as Gallery1 but to avoid confusion i had mentioned it again.

 

 

AndroidManifest.xml :

 

Adding Gallery1 and Gallery2 to manifest file.

 

 

Output

gallery1

gallery2

If you like this tutorial do like and share us.

Show Buttons
Hide Buttons
Read previous post:
Android Tutorial on Progress Bar File Downloading

Close