gpt4 book ai didi

android - 新的 Google Now 和 Google+ 卡片界面

转载 作者:IT老高 更新时间:2023-10-28 13:23:22 25 4
gpt4 key购买 nike

Google Now 和 Google+ (Android) 都使用类似卡片的界面。

enter image description here

我想知道是否有人知道如何在 Android 上复制此界面。

他们都有非常有趣的动画来展示新卡片;任何想法都会很棒。

最佳答案

我已经发布了一个关于如何复制/创建 Google Cards 样式布局的教程 here .

关键步骤

  1. 创建自定义布局
  2. 添加观察者以绘制 child
  3. 动画交替卡片

这是一段代码

@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;
}

}

关于android - 新的 Google Now 和 Google+ 卡片界面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11639991/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com