1

I want to fade from one view to another on in a ViewGroup. At the moment I'm doing the transition using setAlpha, but the problem is that only one view is being rendered, the one that was on top and is fading out.

  • Is the view-array inside ViewGroup an order by z-axis?
  • Is only the top view being rendered?

My layout method looks like this:

@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());
    }
}
Fabian Zeindl
  • 5,860
  • 8
  • 54
  • 78

1 Answers1

2

Why don't you want to use ViewSwitcher? It does exactly what you want. Here is an example.

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

There is no such thing like Z-order in android. Views are drawn in oder they were added to ViewGroup. First added draws first.

Is only the top view being rendered

No, android will draw all views in visible rect even if they are totally overlaped by others.

I think you should fix this place this.getChildAt(0) and layout all childrens in your ViewGroup.

Community
  • 1
  • 1
Leonidos
  • 10,482
  • 2
  • 28
  • 37