Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 317
davidvarghese Avatar asked Sep 12 '14 14:09

davidvarghese


1 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" 
      android:right="10dp"/>
</shape>

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

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

Apply the style on each item in your layout

like image 107
Nipun Anand Avatar answered Oct 16 '22 01:10

Nipun Anand