2

私は自分の好みに合うようにここからCoverFlowをいじっていますが、1つの問題を修正することはできません。スクリーンショットは次のとおりです。

スクリーンショット

中央の画像から右の写真がうまく重なっていない。これが私のコードです:

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の値は完璧です)。どういう意味ですか?最初に小さい写真を描き、次に大きい写真を描く必要がありますか?もしそうなら、どうすればそれを行うことができますか?

4

2 に答える 2

5

getChildDrawingOrderGalleryクラスの関数をオーバーライドして、正しい順序を指定しました。上記の動作は、次のコードで実現できます。

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;
    }
}
于 2012-10-18T17:55:54.677 に答える
0
mCamera.translate(xTranslate, 0.0f, translateDepth);

クラスでは、上記の関数を使用してCoverflow、深さを増やす(より正の値=より小さくする)か、X方向に移動します。また、スケーリングを使用することもできます。値も使用してくださいcenterOffset。目的を果たします。

于 2012-12-31T10:23:49.943 に答える