Android custom Grid View with zoom-in animation effect

Android custom Grid View with zoom-in animation effect

In a Grid View all the views are arranged in the grid fashion. We can customize a Grid View by creating a custom layout for the contents of the grid item.

Here in this example we create a Grid View with the grids containing a simple layout have an Image View that holds a thumbnail.

We have different cases where we need to display those thumbs are the grid views in a separate layout with larger images. We can achieve this by starting a new Activity on a grid item click with the image reference and showing it in that activity.

But here in the example on a grid item (thumbnail) click, we zoom-in form the thumbnail to full screen image with a growing animation effect.

Here’s the Demo of the final Project:

Here are the steps in creating the project:

step 1: Create a New Android Project with a blank activity(MainActivity.java) and a layout(activity_main.xml).

step 2: To the main layout(activity_main.xml) Add a Frame Layout as the root and then a Grid View followed by an Image View – to display the zoomed-in image of the thumbnail:

Note: We use frame layout because we are initially hiding the full screen ImageView and showing it on click on the Grid Item. As all the Views in a frame layout are stacked one on other we can display a View over another View.

For more info on Frame Layouts refer: http://developer.android.com/reference/android/widget/FrameLayout.html

activity_main.xml:

step 3: Create a new layout for the Grid Item (grid_item.xml) with an Image View to hold the thumbnail:

step 4:
The final main Activity(MainActivity.java) looks as follows (Commented wherever necessary for better understanding the flow) :

 

More like this: android

Comments are closed.