Google即时和Google+(Android)均使用类似卡片的界面。新的Google即时和Google+卡界面
我想知道如果任何人有任何想法如何这个接口可以在Android上被复制。
他们都有相当有趣的动画显示新的卡也;任何想法都会很棒。
Google即时和Google+(Android)均使用类似卡片的界面。新的Google即时和Google+卡界面
我想知道如果任何人有任何想法如何这个接口可以在Android上被复制。
他们都有相当有趣的动画显示新的卡也;任何想法都会很棒。
我已经发布了关于如何复制教程/创建谷歌卡片式布局here。
关键步骤
继承人的代码片段
@Override
public void onGlobalLayout() {
getViewTreeObserver().removeGlobalOnLayoutListener(this);
final int heightPx = getContext().getResources().getDisplayMetrics().heightPixels;
boolean inversed = false;
final int childCount = getChildCount();
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
int[] location = new int[2];
child.getLocationOnScreen(location);
if (location[1] > heightPx) {
break;
}
if (!inversed) {
child.startAnimation(AnimationUtils.loadAnimation(getContext(),
R.anim.slide_up_left));
} else {
child.startAnimation(AnimationUtils.loadAnimation(getContext(),
R.anim.slide_up_right));
}
inversed = !inversed;
}
}
这很好。非常感谢你:) – HBG 2012-09-25 10:04:51
好一个!认为下面的链接会有帮助。 https://github.com/nadavfima/cardsui-for-android http://nhaarman.github.io/ListViewAnimations/ – 2013-07-19 11:19:15
@Sharddul我需要把视图动态地进
有同样的需要,并已开始调查一下。 我一直在看我已经能够从com.google.android.googlequicksearchbox apk获得的apktool输出。 (没有资源只有res xmls)
此布局(at_place_card.xml)用于显示位置。 右侧有三个文本行和两个动作按钮(详细信息和签入),左侧有图像。
不幸的是,我无法从apk获取任何样式信息,所以字体大小,尺寸和颜色只是猜测。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:orientation="horizontal" android:background="@drawable/card_background" android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:thegoogle="http://schemas.android.com/apk/res/com.google.android.googlequicksearchbox">
<LinearLayout android:orientation="vertical" android:layout_width="0.0dip" android:layout_height="fill_parent" android:baselineAligned="false" android:layout_weight="1.0">
<FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" style="@style/CardTextBlock">
<TextView android:id="@id/entry_title" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/CardTitle" />
<TextView android:id="@id/open_hours" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/CardText" />
<TextView android:textColor="@color/card_light_text" android:id="@id/known_for_terms" android:paddingBottom="4.0dip" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:maxLines="4" style="@style/CardText" />
</LinearLayout>
<ImageButton android:layout_gravity="top|right|center" android:id="@id/card_menu_button" android:layout_width="@dimen/card_action_button_height" android:layout_height="@dimen/card_action_button_height" android:contentDescription="@string/accessibility_menu_button" style="@style/CardMenuButton" />
</FrameLayout>
<Space android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0" />
<Button android:id="@id/details_button" android:visibility="gone" android:layout_width="fill_parent" android:layout_height="@dimen/card_action_button_height" android:text="@string/more_details" android:drawableLeft="@drawable/ic_action_pin" style="@style/CardActionButtonWithIcon" />
<Button android:id="@id/checkin_button" android:layout_width="fill_parent" android:layout_height="@dimen/card_action_button_height" android:text="@string/check_in" android:drawableLeft="@drawable/ic_action_check_in" style="@style/CardActionButtonWithIcon" />
</LinearLayout>
<com.google.android.velvet.ui.CrossfadingWebImageView android:id="@id/place_photo" android:visibility="gone" android:layout_width="0.0dip" android:layout_height="fill_parent" android:scaleType="centerCrop" android:adjustViewBounds="true" android:baselineAligned="false" android:minHeight="@dimen/at_place_card_content_height" android:layout_weight="1.0" android:contentDescription="@string/at_place_card_image_desc" thegoogle:crossfadeDuration="@integer/image_crossfade_duration" />
</LinearLayout>
更新:现在也能够得到一些样式信息。如果你感兴趣的话,这里是一个带有我目前信息的zip文件(现在有一些来自google的资源文件)。 https://dl.dropbox.com/u/4379928/android/googlenow2.zip
查看我的回答 – confucius 2013-01-31 10:15:14
卡的外观不应该很难。你只需要一个没有分隔符的ListView,你的列表视图项目应该有一个边距。
像这样:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_margin="16dp"
android:layout_height="wrap_content"
android:background="@android:color/background_light">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingRight="16dp"
android:paddingLeft="16dp"
android:text="Title"
android:textSize="18dp"
android:textColor="@android:color/primary_text_holo_light"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingRight="16dp"
android:paddingLeft="16dp"
android:text="Subtitle"
android:textSize="14dp"
android:textColor="@android:color/primary_text_holo_light"
/>
<ImageView android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/background"/>
</LinearLayout>
根据主帖的评论,我认为它更多的是关于卡片的动画,以及如何构建列表而不是布局的内容。 – pommedeterresautee 2012-08-16 21:32:04
感谢您的回答。我已经能够复制这个外观 - 现在我只想让整体感觉也一样! – HBG 2012-08-29 17:14:00
你可以看看我的回答 – confucius 2013-01-31 00:39:22
我做了一个布局非常相似你可以看看这里 https://github.com/Nammari/GooglePlusLayout 和视频演示在这里http://youtu.be/jvfDuJz4fw4 为获得适用于儿童,了解更多详情动画看这里 http://nammari.tumblr.com/post/41893669349/goolge-plus-layout 的博客贴子,明确每一件事情。
/RES /绘制/ bg_card:
在http://ryanharter.com/blog/2013/01/31/how-to-make-an-android-card-list/
复制的例子看看。XML:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle"
android:dither="true">
<corners android:radius="2dp"/>
<solid android:color="#ccc" />
</shape>
</item>
<item android:bottom="2dp">
<shape android:shape="rectangle"
android:dither="true">
<corners android:radius="2dp" />
<solid android:color="@android:color/white" />
<padding android:bottom="8dp"
android:left="8dp"
android:right="8dp"
android:top="8dp" />
</shape>
</item>
</layer-list>
使用它作为您的布局的背景:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:padding="12dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:background="@drawable/bg_card">
<!-- Card Contents go here -->
</LinearLayout>
</FrameLayout>
您可能需要添加填充字段到第一个rect项目 – lalitm 2014-03-01 05:02:26
谢谢修正了这个例子 – userM1433372 2014-03-03 10:10:36
非常感谢:D – jonamreddy 2014-12-15 14:15:37
====开始更新2014年9月29日====
使用CardView从谷歌兼容性库(来自的Android 2.1+):
<!-- A CardView that contains a TextView -->
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="200dp"
card_view:cardCornerRadius="4dp">
<TextView
android:id="@+id/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v7.widget.CardView>
参见https://developer.android.com/preview/material/ui-widgets.html
====结束更新====
(至少)两个选项:
或
查看https://github.com/afollestad/Cards-UI/wiki/2.-Intro-Tutorial的简单介绍。
伟大的工作,我希望这是支持所有的Android版本11 – Harshit 2014-02-12 20:50:13
Cardslib是很棒但是一个14的明斯克使我不可能。Cardsui也有15分钟,它不是很好恕我直言。 – frostymarvelous 2014-06-19 17:24:15
只是为了澄清 - 它更像是我以后的卡片视图的外观和感觉。基本上我需要它的行为像一个ListView,即我可以用卡片动态填充屏幕,但我希望列表中的每一行看起来像一张卡片。如果还有其他布局可以改编,那就太好了 – HBG 2012-07-25 10:10:06
在YouTube上学习视频之后,我认为它就像是有两个视图的列表视图,一个是关闭的卡片,另一个是开放的视图。这两个视图之间也有动画......我认为我们不需要重新创建所有的API来获得相似的结果。 – pommedeterresautee 2012-08-16 21:35:55
请看下面我的回答 – confucius 2013-01-31 00:28:17