Home » Android » Android Layout : How to implement a UI similar to deck of cards?

Android Layout : How to implement a UI similar to deck of cards?

Posted by: admin May 14, 2020 Leave a comment


I needed to implement a layout which is similar to Google Chrome’s stack of tabs as shown below .

Are there any libraries available for this ?

enter image description here

How to&Answers:

You need to create a set custom drawables for each aspect of the card and use them in the layout. You can use table layout for this purpose.

For example to put a background with corners you can create a drawable as follows:

Add new drwabe resource as follows:

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
   android:shape="rectangle" >
   <corners android:radius="5dp"/>
   <stroke android:width="1dp" android:color="choose the color which you want"/>
   <padding android:top="10dp" android:left="10dp" android:bottom="10dp" 

Create a custom style and use the above drawable as background:

<style name="ContactTextView">
      <item name="android:background">@drawable/drawableName</item>
      // add other items 

Apply the style on each item in your layout


Use a RecyclerView with your own LayoutManager. The layoutmanager can than stack it like this. To implement behaviour (like expanding an item on click) you need more code. I coudlnt find an open source project which has this.

Have a look here for help: