首页 \ 问答 \ Android Flip View动画很酷(Android Flip View Animation is Jerky)

Android Flip View动画很酷(Android Flip View Animation is Jerky)

这是一个奇怪的。 我有一个动画,将视图翻转90度,然后另一个视图旋转另一个90度,允许更改图像。 这适用于三星Tab 3; 但是在Tab 4上,动画非常生涩。 如果我打开“配置文件GPU渲染” - “在屏幕上显示为条形图”,动画将变得非常流畅。

我已将调试日志放入动画中,并且我发现applyTransformation函数被称为相同的次数,当它是生涩的并且它是平滑的时。 所以我可以把它归结为屏幕没有足够的刷新。 任何想法都会很棒。

这是翻转动画。 public class AnimatedFlip extends Animation {private final float mFromDegrees; 私人最终浮动mToDegrees; 私人最终浮动mCenterX; 私人最终浮动mCenterY; 私人相机mCamera;

    public AnimatedFlip(float aFromDegrees, float aToDegrees, float aCenterX, float aCenterY)
    {
        mFromDegrees = aFromDegrees;
        mToDegrees = aToDegrees;
        mCenterX = aCenterX;
        mCenterY = aCenterY;
    }

    @Override
    public void initialize(int aWidth, int aHeight, int aParentWidth, int aParentHeight)
    {
        super.initialize(aWidth, aHeight, aParentWidth, aParentHeight);
        mCamera = new Camera();
    }

    @Override
    protected void applyTransformation(float aInterpolatedTime, Transformation aTransformation)
    {
        float degrees = mFromDegrees + ((mToDegrees - mFromDegrees) * aInterpolatedTime);

        final Matrix matrix = aTransformation.getMatrix();

        mCamera.save();
        mCamera.rotateY(degrees);
        mCamera.getMatrix(matrix);
        mCamera.restore();

        matrix.preTranslate(-mCenterX, -mCenterY);
        matrix.postTranslate(mCenterX, mCenterY);
    }
}

通过此调用启动动画。

mFlipStartingView.setVisibility(View.VISIBLE);
applyRotation(0, 90, mFlipStartingView);

这是执行动画的功能。

private void applyRotation(float aStart, float aEnd, final ImageView aView)
{
    // Find the center of image
    float centerX = aView.getWidth() / 2.0f + aView.getX();
    float centerY = aView.getHeight() / 2.0f + aView.getY();

    // Create a new 3D rotation with the supplied parameter
    // The animation listener is used to trigger the next animation
    final AnimatedFlip rotation = new AnimatedFlip(aStart, aEnd, centerX, centerY);
    rotation.setDuration(mFlipAnimationTime);
    rotation.setFillAfter(false);
    rotation.setInterpolator(new LinearInterpolator());
    rotation.setAnimationListener(new Animation.AnimationListener()
    {
        @Override public void onAnimationStart(Animation animation)
        {
        }

        @Override public void onAnimationEnd(Animation animation)
        {
            if (aView != mFlipView)
            {
                mFlipStartingView.setVisibility(View.INVISIBLE);
                mFlipView.setVisibility(View.VISIBLE);
                applyRotation(-89, 0, mFlipView);
            }
        }

        @Override public void onAnimationRepeat(Animation animation)
        {
        }
    });
    aView.startAnimation(rotation);
}

This is an odd one. I have an animation that flips a view 90 degrees and then another view is rotated the other 90 degrees, allowing for a change of image. This works and it works well on the Samsung Tab 3; however on the Tab 4 the animation is very jerky. If I turn on the 'Profile GPU rendering' - 'Show on screen as bars' the animation becomes very smooth.

I have put debug logs in the animation, and I have found the applyTransformation function is called the same amount of times, when it is jerky and when it is smooth. So all I can put it down to is the screen isn't being refreshed enough. Any thoughts would be great.

Here is the Flip animation. public class AnimatedFlip extends Animation { private final float mFromDegrees; private final float mToDegrees; private final float mCenterX; private final float mCenterY; private Camera mCamera;

    public AnimatedFlip(float aFromDegrees, float aToDegrees, float aCenterX, float aCenterY)
    {
        mFromDegrees = aFromDegrees;
        mToDegrees = aToDegrees;
        mCenterX = aCenterX;
        mCenterY = aCenterY;
    }

    @Override
    public void initialize(int aWidth, int aHeight, int aParentWidth, int aParentHeight)
    {
        super.initialize(aWidth, aHeight, aParentWidth, aParentHeight);
        mCamera = new Camera();
    }

    @Override
    protected void applyTransformation(float aInterpolatedTime, Transformation aTransformation)
    {
        float degrees = mFromDegrees + ((mToDegrees - mFromDegrees) * aInterpolatedTime);

        final Matrix matrix = aTransformation.getMatrix();

        mCamera.save();
        mCamera.rotateY(degrees);
        mCamera.getMatrix(matrix);
        mCamera.restore();

        matrix.preTranslate(-mCenterX, -mCenterY);
        matrix.postTranslate(mCenterX, mCenterY);
    }
}

The animation is started with this call.

mFlipStartingView.setVisibility(View.VISIBLE);
applyRotation(0, 90, mFlipStartingView);

This is the function that does the animation.

private void applyRotation(float aStart, float aEnd, final ImageView aView)
{
    // Find the center of image
    float centerX = aView.getWidth() / 2.0f + aView.getX();
    float centerY = aView.getHeight() / 2.0f + aView.getY();

    // Create a new 3D rotation with the supplied parameter
    // The animation listener is used to trigger the next animation
    final AnimatedFlip rotation = new AnimatedFlip(aStart, aEnd, centerX, centerY);
    rotation.setDuration(mFlipAnimationTime);
    rotation.setFillAfter(false);
    rotation.setInterpolator(new LinearInterpolator());
    rotation.setAnimationListener(new Animation.AnimationListener()
    {
        @Override public void onAnimationStart(Animation animation)
        {
        }

        @Override public void onAnimationEnd(Animation animation)
        {
            if (aView != mFlipView)
            {
                mFlipStartingView.setVisibility(View.INVISIBLE);
                mFlipView.setVisibility(View.VISIBLE);
                applyRotation(-89, 0, mFlipView);
            }
        }

        @Override public void onAnimationRepeat(Animation animation)
        {
        }
    });
    aView.startAnimation(rotation);
}

原文:https://stackoverflow.com/questions/29957821
更新时间:2023-05-24 19:05

最满意答案

所以我决定再看一下如何在ClientCrypter类中编译它。 并且正在考虑不同的编译器选项是否会导致此问题。 并得出结论,删除线:

ProviderOptions.Add("CompilerVersion", "v2.0");

修复了问题,应用程序运行和工作


So I decided to take a look again at how I compile it in the ClientCrypter class. And was thinking if different compiler options could cause this problem. And came to the conclusion that removing the line:

ProviderOptions.Add("CompilerVersion", "v2.0");

Fixed the issue and the application ran and worked

相关问答

更多
  • 你只需要将你的.exe文件复制到同一个目录。 您可以使用ILMerge util 你可以从msdn下载它 You need just copy your dll file with exe file into the same directory. and you can use the ILMerge util you can download it from msdn
  • 我认为你所说的是在你的面板中嵌入一个应用程序。 这仅适用于已创建为嵌入的可执行文件。 记事本不是其中之一。 有些浏览器可以 - Mozilla就是一个例子,而IE则是另一个例子。 I think what you are talking about is embedding an application in your panel. This is only possibly with executables that have been created to be embedded. Notepad is ...
  • 如果我们谈论的是非托管可执行文件,那么答案就是否定。 为什么? 没有合理的共享主机将允许您运行非托管可执行文件,因为没有安全性。 如果我们谈论.NET可执行文件,你可以直接通过引用引用它,并调用你需要的函数(这是有效的,因为.NET提供了强大的安全性,你可以约束所有东西)。 它仍然可以上传可执行文件,但这有点无用,除非您想将其用于共享目的(在控制面板中启用它)。 If we are talking about unmanaged executable, then the answer is no. Why? ...
  • 所以我决定再看一下如何在ClientCrypter类中编译它。 并且正在考虑不同的编译器选项是否会导致此问题。 并得出结论,删除线: ProviderOptions.Add("CompilerVersion", "v2.0"); 修复了问题,应用程序运行和工作 So I decided to take a look again at how I compile it in the ClientCrypter class. And was thinking if different compiler opt ...
  • 根据它的.NET版本以及它使用的库,您可以尝试在Mono下运行它,而无需将IL编译为本机代码。 大多数Linux发行版都在其包管理系统下提供。 请参阅: http : //www.mono-project.com/Main_Page了解更多详情 另一种方法是使用NGen进行编译( http://blogs.msdn.com/clrcodegeneration/archive/2007/09/15/to-ngen-or-not-to-ngen.aspx )。 但我不确定它会在WINE下运作。 dependin ...
  • 这真的很有趣。 默认情况下,我相信Excel COM组件设置为以交互式用户身份运行(即用户登录框)。 如果它们被配置为以启动用户 身份运行 ,那么模拟应该可以工作。 当然,这并不能解释为什么“Run As ...”有效(我不知道它的机制,所以它可能不是模仿)。 一个想法是重构应用程序以将文件复制到Excel可以访问的位置,操作它们,然后复制后面。 This is really interesting. By default, I believe the Excel COM components are se ...
  • 我不知道它为什么会削减搜索路径,但我的解决方案是将值分配给文本标签,然后为fsxExePath分配标签的值,如下所示: ' Hack to get fsxExePath... Label1.Text = fsxPath Label1.Text = Label1.Text & "fsx.exe" fsxExePath = Label1.Text Label1.Text = "" I don't know why it cuts the search path, ho ...
  • 您可以编写这段代码来关闭命令: - start /d "path" %synchronizerDir%\Synchronizer.exe You can write this piece of code to close command:- start /d "path" %synchronizerDir%\Synchronizer.exe
  • 我讨厌启动其他应用程序并尝试控制它们。 如果可能的话,我建议尝试以编程方式模仿msg.exe的功能。 从做一些快速的谷歌搜索,我发现msg.exe使用的API函数显然是WTSSendMessage中的WTSSendMessage。 这是关于该功能的MSDN文章: http://msdn.microsoft.com/en-us/library/windows/desktop/aa383842(v=vs.85).aspx 这是一个链接,显示如何从.NET调用该API函数: http://www.pinvoke. ...
  • 答案是这样的: sudo apt-get install mono-runtime sudo apt-get install libmono-SYSTEM* sudo apt-get update mono application.exe 这将运行我的应用程序。 可能如果其他人获得了除winforms之外的其他东西,可能还需要其他软件包。 Answer is this: sudo apt-get install mono-runtime sudo apt-get install libmono-SYSTE ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)