【问题标题】:Android Cover FlowAndroid 封面流程
【发布时间】:2013-04-04 03:37:21
【问题描述】:

我在我的 Android 应用程序中使用本教程链接 http://www.inter-fuser.com/2010/01/android-coverflow-widget.html 的封面流程,并且我已经很好地使用了它。但我的问题是,当 Android 版本为 4.1 时,封面流程无法正常工作,因为选择图像后图像没有居中或对齐。但是,如果 Android 版本低于 4.0,它就像在链接的视频中一样运行良好。

有人对这个问题有想法吗?

【问题讨论】:

    标签: android coverflow


    【解决方案1】:

    更新

    解决此问题的方法是对 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() 与视图的左侧对齐,因此您必须计算中间的 y0urself。如果布局填满屏幕,您将不得不在视图的左侧和右侧应用填充以强制选定元素居中。

    请注意。水平滚动视图没有动画滚动,因此它将是一种快速行为。您可以通过使用计时器滚动来解决此问题,但这不是一个非常优雅的解决方案。

    【讨论】:

    • @user2031308,你是怎么解决这个问题的,我也遇到了同样的问题。
    • @kaibuki 我已经完全放弃了这个实现,但希望这会有所帮助......stackoverflow.com/questions/13014715/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-17
    • 1970-01-01
    • 2021-08-19
    相关资源
    最近更新 更多