title: android 3d vertical carousel view
body: <p>I am using <a href="http://www.codeproject.com/Articles/146145/Android-3D-Carousel" rel="nofollow noreferrer">http://www.codeproject.com/Articles/146145/Android-3D-Carousel</a> code to create a vertical carousel view.i can see the vertical carousel using below changes in the code but center item is not properly placed in the screen and if the list items size increased, diameter moves upwards.</p>
  
  <pre><code>private void setUpChild(CarouselImageView child, int index, float angleOffset) {
    // Ignore any layout parameters for child, use wrap content
    addViewInLayout(child, -1 /*index*/, generateDefaultLayoutParams());
  
    child.setSelected(index == mSelectedPosition);
  
    int h;
    int w;
  
    if (mInLayout)
    {
      h = (getMeasuredHeight() - getPaddingBottom()-getPaddingTop())/3;
      w = getMeasuredWidth() - getPaddingLeft() - getPaddingRight()/3; 
    }
    else
    {
      h = (getMeasuredHeight() - getPaddingBottom()-getPaddingTop())/3;
      w = getMeasuredWidth() - getPaddingLeft() - getPaddingRight()/3;            
    }
  
    child.setCurrentAngle(angleOffset);
    // modify the diameter.    
    Calculate3DPosition(child, w*(getAdapter().getCount()/4), angleOffset);
  
    // Measure child
    child.measure(w, h);
  
    int childLeft;
  
    // Position vertically based on gravity setting
    int childTop = calculateTop(child, true);
  
    childLeft = 0;
  
    child.layout(childLeft, childTop, w, h);
  }
  </code></pre>
  
  <p>change in <code>calculate3position</code> function as below </p>
  
  <pre><code>float x = (float) (-diameter/2 * Math.cos(angleOffset) * 0.00001);
  float z = diameter/2 * (1.0f - (float)Math.cos(angleOffset));            
  float y = (float) (diameter/2 * Math.sin(angleOffset)) + diameter/2 - child.getWidth();
  child.setX(x);  
  child.setZ(z);  
  child.setY(y);
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/a5r2f.png" alt="attached o/p of 4 list items"><img src="https://i.stack.imgur.com/nOG6L.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/NzPLv.png" alt="o/p of 12 list items , diameter movew upward"></p>