我需要实现一种类似于Google Chrome浏览器选项卡的布局,如下所示。
是否有任何可用的库?
最佳答案
您需要为卡片的各个方面创建一组自定义可绘制对象,并在布局中使用它们。您可以为此使用表格布局。
例如,要放置带有角的背景,可以创建如下的可绘制对象:
添加新的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>
创建一个自定义样式,并使用上面的drawable作为背景:
<style name="ContactTextView">
<item name="android:background">@drawable/drawableName</item>
// add other items
</style>
将样式应用于布局中的每个项目
关于Android布局: How to implement a UI similar to deck of cards?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25810586/