Android Gallery CoverFlow中的坏图像重叠

Android Gallery CoverFlow中的坏图像重叠,android,gallery,coverflow,Android,Gallery,Coverflow,我正在修补CoverFlow以匹配我的偏好,但无法解决一个问题。以下是截图: 中间图像右侧的图片重叠不良。这是我的密码: protected boolean getChildStaticTransformation(View child, Transformation t) { final int childCenter = getCenterOfView(child); int rotationAngle = 0; t.clear(); t.setTransformatio

我正在修补CoverFlow以匹配我的偏好,但无法解决一个问题。以下是截图:

中间图像右侧的图片重叠不良。这是我的密码:

protected boolean getChildStaticTransformation(View child, Transformation t) {

  final int childCenter = getCenterOfView(child);
  int rotationAngle = 0;
  t.clear();
  t.setTransformationType(Transformation.TYPE_MATRIX);

    if (childCenter == mCoveflowCenter) {
        transformImageBitmap((ImageView) child, t, 0);
    } else {      
        rotationAngle = Math.abs(mCoveflowCenter - childCenter);
        transformImageBitmap((ImageView) child, t, rotationAngle);         
    }    

return true;
}

/**
* This is called during layout when the size of this view has changed. If
* you were just added to the view hierarchy, you're called with the old
* values of 0.
*
* @param w Current width of this view.
* @param h Current height of this view.
* @param oldw Old width of this view.
* @param oldh Old height of this view.
 */
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
  mCoveflowCenter = getCenterOfCoverflow();
  super.onSizeChanged(w, h, oldw, oldh);
 }

 /**
  * Transform the Image Bitmap by the Angle passed 
  * 
  * @param imageView ImageView the ImageView whose bitmap we want to rotate
  * @param t transformation 
  * @param rotationAngle the Angle by which to rotate the Bitmap
  */
 private void transformImageBitmap(ImageView child, Transformation t, int rotationAngle) {            
  mCamera.save();
  final Matrix imageMatrix = t.getMatrix();
  final int imageHeight = child.getLayoutParams().height;
  final int imageWidth = child.getLayoutParams().width;

  mCamera.translate(0.0f, 0.0f, 100.0f);

  float zoomAmount = 0;
  //skalowanie za pomocą translate nie rotational angle?
  zoomAmount = Math.abs((float) (rotationAngle));

  Log.v("zoom", Float.toString(zoomAmount));
  mCamera.translate(0.0f, 0.0f, zoomAmount - 300.0f);          

  mCamera.getMatrix(imageMatrix);               
  imageMatrix.preTranslate(-(imageWidth/2), -(imageHeight/2)); 
  imageMatrix.postTranslate((imageWidth/2), (imageHeight/2));
  mCamera.restore();
}

它为每一张图片转换相机,因此较小的图片更容易进入屏幕(在logcat中,值是完美的)。这是什么意思?我必须先画小一点的,然后再画大一点的,等等吗。?如果是这样,我该怎么做呢?

您已经通过重写Gallery类的
getChildDrawingOrder
函数指定了正确的顺序。上述行为可通过以下代码实现:

int lastPosition;

@Override
protected int getChildDrawingOrder(int childCount, int i) {

    if (i == 0)
        lastPosition = 0;

    int centerPosition = getSelectedItemPosition()
            - getFirstVisiblePosition();

    if (i == childCount - 1) {
        return centerPosition;
    } else if (i >= centerPosition) {
        lastPosition++;
        return childCount - lastPosition;
    } else {
        return i;
    }
}

Coverflow
类中,使用上述函数增加深度(越正=越小)或沿
X
方向平移。也可以使用一些缩放。同时使用
中心偏移量
值。服务于此目的。

你好,Ajith,当我使用cover flow时,请看这个问题,并尝试根据您在此处的重播修改代码,但我不知道在哪里使用这个问题。如果您对此有任何想法,请提供帮助。提前感谢。不要忘记调用
setChildrenDrawingOrderEnabled(true)
mCamera.translate(xTranslate, 0.0f, translateDepth);