gpt4 book ai didi

Android View 组 : fade/blend two views on top of each other

转载 作者:行者123 更新时间:2023-11-29 21:51:48 25 4
gpt4 key购买 nike

我想在 ViewGroup 中从一个 View 淡出到另一个 View 。目前我正在使用 setAlpha 进行转换,但问题是只渲染了一个 View ,即位于顶部但正在淡出的 View 。

  • ViewGroup 中的 View 数组是否按 z 轴排序?
  • 是否只渲染了顶 View ?

我的 layout 方法如下所示:

@Override
protected void onLayout(final boolean changed, final int l, final int t, final int r, final int b) {
L.debug("laying out {} children", this.getChildCount());
for (int i = 0; i < this.getChildCount(); i++) {
L.debug("layout out {}", i);

View view = this.getChildAt(0);
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
}
}

最佳答案

您为什么不想使用 ViewSwitcher?它正是你想要的。这是一个 example .

Is the view-array inside ViewGroup an order by z-axis?

Android 中没有 Z-order 这样的东西。 View 按照添加到 ViewGroup 的顺序绘制。首先添加抽签。

Is only the top view being rendered

不,android 将在可见矩形中绘制所有 View ,即使它们与其他 View 完全重叠也是如此。

我认为你应该修复这个地方 this.getChildAt(0) 并在你的 ViewGroup 中布置所有的 child 。

关于Android View 组 : fade/blend two views on top of each other,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14203067/

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