2012-04-18 40 views

Respuesta

9

I utilizarse Camera.setTranslate(x, 0, z) en drawChild, donde cambia la posición x para la virtualización de rotación y z para overlaping. Luego hubo un problema con la superposición, ya que el último elemento estaba en la parte superior y el primero en la capa inferior. Por lo tanto, en el método onCreate() llamado this.setChildrenDrawingOrderEnabled(true) y reemplazado protected int getChildDrawingOrder (int childCount, int i) {} donde podría cambiar el orden para las filas centrales y posteriores. Esta idea fue dada por Renard, quien me sugirió en mi otra publicación casi lo mismo here.

Mi getChildDrawingOrder (int, int) aplicación para obtener la superposición que necesito:

@Override 
protected int getChildDrawingOrder (int childCount, int i) { 
    int centerChild = 0; 
    //find center row 
    if ((childCount % 2) == 0) { //even childCount number 
     centerChild = childCount/2; // if childCount 8 (actualy 0 - 7), then 4 and 4-1 = 3 is in centre.  
     int otherCenterChild = centerChild - 1; 
     //Which more in center? 
     View child = this.getChildAt(centerChild); 
     final int top = child.getTop(); 
     final int bottom = child.getBottom(); 
     //if this row goes through center then this 
     final int absParentCenterY = getTop() + getHeight()/2; 
     //Log.i("even", i + " from " + (childCount - 1) + ", while centerChild = " + centerChild); 
     if ((top < absParentCenterY) && (bottom > absParentCenterY)) { 
      //this child is in center line, so it is last 
      //centerChild is in center, no need to change 
     } else { 
      centerChild = otherCenterChild; 
     } 
    } 
    else {//not even - done 
     centerChild = childCount/2; 
     //Log.i("not even", i + " from " + (childCount - 1) + ", while centerChild = " + centerChild); 
    } 

    int rez = i; 
    //find drawIndex by centerChild 
    if (i > centerChild) { 
     //below center 
     rez = (childCount - 1) - i + centerChild; 
    } else if (i == centerChild) { 
     //center row 
     //draw it last 
     rez = childCount - 1; 
    } else { 
     //above center - draw as always 
     // i < centerChild 
     rez = i; 
    } 
    //Log.i("return", "" + rez); 
    return rez; 

} 

espero que este post va a ayudar a alguien en el futuro

captura de pantalla es en realidad casi lo mismo que he mencionado en mi pregunta . Solía ​​alfa, por lo que los elementos superpuestos está un poco ver a través de:

enter image description here

+0

@pengwang ¿qué demostración? ¿Quieres decir captura de pantalla del resultado? –

+0

sí, tienes razón, puedes compartir tu captura de pantalla del código de resultado – pengwang

+0

@PooLaS por favor dame el enlace de preferencia o publica tus clases para entender esto para implementar. –