如何在列表视图中创建谷歌+卡的用户界面? [英] How to create Google + cards UI in a list view?
问题描述
我想创建卡列表视图,但看完这篇博客文章 Goolge的加布局<后/一>,我卡是任何东西列表的可行的解决方案。动画部分似乎太内存密集型负载说同时与超过40个元素的列表视图。
I want to create a listView of cards, but after reading this blog post goolge-plus-layout, I'm cards are a viable solution for a list of anything. The animation part seems too memory intensive to load say a listview with more than 40 elements simultaneously.
有没有更好的方式来实现的ListView一卡的用户界面?
Is there a better way to achieve a cards UI in listView?
推荐答案
您可以创建自定义绘制,并将其应用到每个列表视图元素。
You can create a custom drawable, and apply that to each of your listview elements.
我用我的UI这一个卡。我不认为有这种做法显著的性能问题。
I use this one for cards in my UI. I don't think there is significant performance issues with this approach.
提拉code(在绘制\ big_card.xml)看起来是这样的:
The drawable code (in drawable\big_card.xml) looks like this:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<solid android:color="@color/second_grey" />
</shape>
</item>
<item
android:bottom="10dp"
android:left="10dp"
android:right="10dp"
android:top="10dp">
<shape android:shape="rectangle" >
<corners android:radius="3dp" />
<solid android:color="@color/card_shadow" />
</shape>
</item>
<item
android:bottom="12dp"
android:left="10dp"
android:right="10dp"
android:top="10dp">
<shape android:shape="rectangle" >
<corners android:radius="3dp" />
<solid android:color="@color/card_white" />
</shape>
</item>
</layer-list>
我申请的背景,我的列表视图内容是这样的:
I apply the background to my listview elements like this:
<ListView
android:id="@+id/apps_fragment_list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="@drawable/big_card" />
如果你想添加为背景,以任何View(不只是一个列表),你只要把自定义绘制的视图的背景元素:
If you want to add this as a background to any View (not just a list), you just make the custom drawable that View's background element:
<TextView
android:id="@+id/any_view"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/big_card" />
这篇关于如何在列表视图中创建谷歌+卡的用户界面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!