2013-04-04 77 views

回答

1

UPDATE

针对此问题的解决方法是进行以下更改getChildStaticTransformation(View child, Transformation t)

protected boolean getChildStaticTransformation(View child, Transformation t) { 
       child.invalidate(); // add this line 
       final int childCenter = getCenterOfView(child); 
       final int childWidth = child.getWidth(); 
       int rotationAngle = 0; 

       t.clear(); 
       t.setTransformationType(Transformation.TYPE_MATRIX); 

       if (childCenter == mCoveflowCenter) { 
         transformImageBitmap((ImageView) child, t, 0); 
       } else { 
         rotationAngle = (int) (((float) (mCoveflowCenter - childCenter)/childWidth) * mMaxRotationAngle); 
         if (Math.abs(rotationAngle) > mMaxRotationAngle) { 
           rotationAngle = (rotationAngle < 0) ? -mMaxRotationAngle 
               : mMaxRotationAngle; 
         } 
         transformImageBitmap((ImageView) child, t, rotationAngle); 
       } 

       return true; 
     } 

-

最近我有同样的问题。这与Gallery已被弃用有关。作为替代,我使用Horizo​​ntalScrollView和使用.scrollTo()进行居中实现了类似于此的东西。这个解决方案的问题是scrollTo()与View的左侧对齐,所以你必须计算中间的yOurself。如果布局填充屏幕,则必须在视图的左侧和右侧应用填充以强制所选元素居中。

一句谨慎。水平滚动视图没有可滚动的动画,因此它将成为一个单元行为。你可以通过使用定时器滚动来解决这个问题,但这不是一个非常优雅的解决方案。

+0

你解决了这个问题吗? – 2013-04-04 05:04:21

+0

没关系我只是解决了它谢谢 – 2013-04-04 05:08:57

+0

@ user2031308,你是如何解决这个问题的,我有同样的问题。 – kaibuki 2013-10-09 09:27:14