Android StackView - Androhub

StackView

Android StackView

StackView helps in arranging items in the form of stacked cards, where the front item can be flipped to bring the item behind it to the front. In addition to images, you can stack objects composed of text and other data, too.

Example

In this example I will show how to make use of stack images in the StackView.

VIDEO DEMO

Let’s get start by creating a project in Eclipse IDE.

1. Create a new project in Eclipse by navigating to File ⇒ New Android ⇒ Application Project and fill required details. (I kept my main activity name as MainActivity.java)

2.  Create a layout file for MainActivtiy.java under res ⇒ layout folder. I named the layout file as activity_main.xml. In this layout i had taken StackView for showing stack of images.

3. Before, making stackview of images you have to create a custom xml layout and custom adapter for it like we had done in listview and gridview. Now, create a new xml file for custom layout naming display_item.xml.

4. Now create a getter setter class for custom adadpter naming Stack_Items.java.

5. Now make custom adapter class naming Stack_Adapter.java  and add the following code.

6. Finally come to MainActivity.java and add the following code. In this class we just had taken arraylist for images and texts and just setting the custom adapter over the stackview.

7. Now, run the app and you will get the output as shown in video.

Thanks. :)

 

3 Comments

Wasim
Thursday, October 8th, 2015

hey thanks for this tutorial its very rear.

Can i put images in same row i mean they are like stairs but i want them like on top of each other ?

I hope you understand my point.

Thanks.

Droid
Friday, October 9th, 2015

Yeah, we can achieve this thing also with some more effort. But right now i am not having any demo to show.

sitara
Thursday, October 15th, 2015

How can I arrange screens(acivities) instead of images in the demo?

Post comment

Your email address will not be published. Required fields are marked *