Android布局:如何实现类似于卡片组的UI?

use*_*376 11 android android-layout

我需要实现一个与Google Chrome的标签页类似的布局,如下所示.

有没有可用的库?

在此输入图像描述

Nip*_*and 1

您需要为卡片的每个方面创建一组自定义可绘制对象,并在布局中使用它们。您可以使用表格布局来实现此目的。

例如,要放置带角的背景,您可以创建一个可绘制对象,如下所示:

添加新的 drwabe 资源如下:

<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>
Run Code Online (Sandbox Code Playgroud)

创建自定义样式并使用上面的可绘制对象作为背景:

<style name="ContactTextView">
      <item name="android:background">@drawable/drawableName</item>
      // add other items 
</style>
Run Code Online (Sandbox Code Playgroud)

将样式应用于布局中的每个项目