Android的布局:如何实现类似于扑克牌的UI? [英] Android Layout : How to implement a UI similar to deck of cards?

查看:189
本文介绍了Android的布局:如何实现类似于扑克牌的UI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现一个布局,类似于标签的谷歌Chrome浏览器的堆栈,如下图所示。

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

是否有可用于此的库?

推荐答案

您需要创建一组自定义可绘制的卡的各个方面,并利用它们的布局。您可以使用表格布局用于此目的。

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:

添加新drwabe资源,如下所示:

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

这篇关于Android的布局:如何实现类似于扑克牌的UI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆