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
最满意答案
所以我决定再看一下如何在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? ...
-
更改.net exe不运行(Changed .net exe doesnt run)[2023-07-21]
所以我决定再看一下如何在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 ...
-
通过BAT文件运行EXE(Run EXE through BAT file)[2021-09-15]
您可以编写这段代码来关闭命令: - 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. ...
-
如何在Linux中运行.Net Framework中的编译.exe(Ways to run compiled .exe from .Net Framework in Linux)[2022-03-07]
答案是这样的: 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 ...