1

我想在ViewGroup. 目前我正在使用 进行过渡setAlpha,但问题是只呈现一个视图,即位于顶部且正在淡出的视图。

  • 视图数组是否ViewGroup按 z 轴排列?
  • 只渲染顶视图吗?

我的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());
    }
}
4

1 回答 1

2

为什么不想使用 ViewSwitcher?它完全符合您的要求。这是一个例子

ViewGroup 中的视图数组是按 z 轴排列的吗?

android中没有像Z-order这样的东西。视图按照添加到 ViewGroup 的顺序绘制。先加抽奖。

是否仅渲染顶视图

不,即使它们完全被其他视图重叠,android 也会在可见矩形中绘制所有视图。

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

于 2013-01-18T12:11:32.160 回答