画廊与Android的中心形象zoomedin画廊、形象、中心、zoomedin

2023-09-07 04:27:21 作者:一纸情书

我使用席上通过它滚动显示图像。我已经使用 getChildStaticTransformation(查看孩子,变换T)方法应用转换到每个那就是每个图像的孩子。

I am using gallery for displaying images by scrolling through it. I have used getChildStaticTransformation(View child,Transformation t) method for applying transformations to each child that is to each of the images.

但现在我想用按钮滚动影像。因此,我调用方法 getChildStaticTransformation 从按钮的 onTouch 事件。但是,图像不动。

But now I want to use buttons to scroll through images. So I am calling the method getChildStaticTransformation from the onTouch event of button. But the images are not moving.

在code如下: -

The code is as follows:-

在我已经使用了类的构造函数,

In the constructor of the class i have used,

    this.setStaticTransformationsEnabled(true);

所以下面的方法是越来越本身解雇所有,当我滚动screen.But我想使用按钮点击方法now.I试图调用内部按钮该方法点击明确,但它不工作。

so the below method is getting fired all by itself when i scroll the screen.But i want to use the method on button click now.I have tried calling this method inside button click explicitly but it is not working.

protected boolean getChildStaticTransformation(View child, Transformation t) {

    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;
}

请帮我。

推荐答案

你有没有尝试调用的无效在像 getChildStaticTransformation()方法 child.invalidate(); ?要更新孩子的静态变换每一次,你需要调用无效()在各自的孩子。如果您仍然有通过图像移动,而按钮点击的问题,你可以按照这个伟大的example,所以,你会得到关于如何通过影像去点击按钮基本理念。如果你能在那里实际上它是怎么了?发表您的code段,有可能是有我的答案编辑的机会。希望这有助于。

Did you try calling invalidate in the getChildStaticTransformation() method like child.invalidate();? Every time you want to update a child's static transform, you need to call invalidate() on respective child. If you still have problems in moving through images while clicking on the buttons, you can follow this great example, So that you would get basic idea on how to go through images with button clicks. If you could post your code snippets where actually it is going wrong, there could be chances of having my answer edited. Hope this helps.