{"id":411,"date":"2012-04-04T01:19:58","date_gmt":"2012-04-03T17:19:58","guid":{"rendered":"http:\/\/guoh.ai\/lifelog\/?p=411"},"modified":"2012-04-04T01:32:28","modified_gmt":"2012-04-03T17:32:28","slug":"android-customized-curved-path-animation","status":"publish","type":"post","link":"https:\/\/guoh.ai\/lifelog\/2012\/04\/android-customized-curved-path-animation\/","title":{"rendered":"Android\u81ea\u5b9a\u4e49\u52a8\u753b\u4e4b\u66f2\u7ebf\u8f68\u8ff9"},"content":{"rendered":"<div class=\"gfmr-markdown-container\"><div class=\"gfmr-markdown-source\" style=\"display: none;\">&lt;p&gt;Android\u652f\u6301\u7684\u52a8\u753b\u7cfb\u7edf\u5927\u4f53\u4e0a\u5206\u4e3a\u4e24\u79cd\uff0c\u5206\u522b\u662f&lt;a href=&quot;http:\/\/developer.android.com\/guide\/topics\/graphics\/view-animation.html&quot; target=&quot;_blank&quot;&gt;View Animation&lt;\/a&gt;\u548c&lt;a href=&quot;http:\/\/developer.android.com\/guide\/topics\/graphics\/prop-animation.html&quot; target=&quot;_blank&quot;&gt;Property Animation&lt;\/a&gt;\uff0c\u603b\u4f53\u6765\u8bf4\u63a8\u8350\u4f7f\u7528Property Animation\uff0cProperty Animation\u66f4\u5f3a\u5927\uff0c\u4f46\u662f\u5982\u679cView Animation\u80fd\u6ee1\u8db3\u4f60\u7684\u9700\u8981\u7684\u8bdd\u6216\u8005\u56e0\u4e3a\u6761\u4ef6\u9650\u5236\u53ea\u80fd\u4f7f\u7528View Animation\uff0c\u90a3\u4e48\u5f53\u7136\u8fd8\u662f\u9009\u62e9View Animation\u3002\u529f\u80fd\u66f4\u591a\u66f4\u5f3a\u5927\u7684\u4e1c\u897f\u610f\u5473\u7740\u4f60\u8981\u4ed8\u51fa\u66f4\u591a\u7684\u52aa\u529b\u6765\u5b9e\u73b0\u548c\u7ef4\u62a4\u5b83\uff0c\u8fd9\u662f\u6e38\u620f\u89c4\u5219\u3002\u95f2\u8bdd\u626f\u8fdc\u4e86\uff0c\u56de\u5230\u4e3b\u9898\uff0c\u8fd8\u6709\u4e00\u70b9\u5c31\u662fProperty Animation\u5728API Level 11\u624d\u5f00\u59cb\u652f\u6301\u3002\u66f4\u591a\u7684\u4ecb\u7ecd\u53ef\u4ee5\u53c2\u770b\u5b98\u65b9\u7684\u6587\u6863\u3002&lt;\/p&gt;\n&lt;p&gt;\u8fd9\u4e24\u79cd\u65b9\u5f0f\u7684\u4f7f\u7528\u90fd\u8fd8\u6bd4\u8f83\u7b80\u5355\u3002\u5728View Animation\u4e2d\u901a\u5e38\u662f\u5b9e\u73b0translate\u3001alpha\u3001scale\u548crotate\u5176\u4e2d\u7684\u4e00\u79cd\u6216\u591a\u79cd(\u5177\u4f53\u7684\u53ef\u4ee5\u901a\u8fc7\u5199\u4ee3\u7801\u6216\u8005\u914d\u7f6eXML\u5b9e\u73b0\uff0c\u5176\u5b9e\u6700\u7ec8\u90fd\u662f\u4e00\u6837\u7684)\u3002\u5728Proerty Animation\u4e2d\u4e5f\u662f\u6307\u5b9a\u8981\u8fdb\u884c\u52a8\u753b\u7684\u5c5e\u6027\uff0c\u6bd4\u5982x\u3001y\u3001alpha\u3001rotation\u6216\u8005scaleX(scaleY)\u7b49\u7b49\u3002\u53c2\u8003docs\u548csamples\u53ef\u4ee5\u5f88\u5feb\u5b9e\u73b0\u57fa\u672c\u52a8\u753b\u3002&lt;\/p&gt;\n&lt;p&gt;\u4f46\u662f\u6709\u65f6\u5019\u6211\u4eec\u9700\u8981\u7684\u6bd4\u8fd9\u4e9b\u57fa\u7840\u529f\u80fd\u8981\u7a0d\u5fae\u590d\u6742\u70b9\u7684\u4e1c\u897f\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u6211\u4eec\u6765\u6269\u5c55\u4e86\u3002\u73b0\u5728\u6211\u4eec\u6765\u5b9e\u73b0\u4e00\u4e2a\u8fd0\u52a8\u8f68\u8ff9\u662f\u66f2\u7ebf\u7684\u52a8\u753b\uff0c\u57fa\u7840\u7684translate\u52a8\u753b\u7684\u8fd0\u52a8\u8f68\u8ff9\u662f\u70b9\u5230\u70b9\u7684\uff0c\u76f4\u7ebf\u7684\u3002&lt;\/p&gt;\n&lt;p&gt;\u5728Property Animation\u4e2d\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003http:\/\/code.google.com\/p\/android-path-animation\/\u8fd9\u4e2a\u4f8b\u5b50\u6765\u5b9e\u73b0\uff0c\u7b80\u5355\u660e\u4e86\u3002\u4f8b\u5b50\u7684\u4f5c\u8005\u4e5f\u662fAndroid Project\u7684Committer\uff0c\u6240\u4ee5\u8fd8\u662f\u5f88\u6709\u5206\u91cf\u7684\u3002&lt;\/p&gt;\n&lt;p&gt;\u5728View Animation\u4e2d\u5c31\u9700\u8981\u81ea\u5df1\u5b9a\u4e49\u4e00\u4e2a\u52a8\u753b\u6765\u5b9e\u73b0\u4e86\uff0cTranslateAnimation\u7684\u8fd0\u52a8\u8f68\u8ff9\u662f\u76f4\u7ebf\uff0c\u65e2\u7136\u6211\u4eec\u9700\u8981\u66f2\u7ebf\u7684\u8f68\u8ff9\uff0c\u90a3\u4e48\u60f3\u5f53\u7136\u6211\u4eec\u53ea\u9700\u8981\u4fee\u6539\u90e8\u5206\u4ee3\u7801\u5c31\u53ef\u4ee5\u4e86\u3002\u539f\u672c\u60f3\u6765\u7ee7\u627fTranslateAnimation\u8fd9\u4e2a\u7c7b\u7684\uff0c\u4f46\u662f\u53d1\u73b0\u8fd9\u4e2a\u7c7b\u91cc\u9762\u6211\u4eec\u9700\u8981\u7684\u53d8\u91cf\u548c\u65b9\u6cd5\u90fd\u662fprivate\u6216\u8005package\uff0c\u6240\u4ee5\u53ea\u597d\u628a\u8fd9\u4e2a\u7c7b\u7684\u4ee3\u7801\u62f7\u8d1d\u4e00\u4efd\u81ea\u5df1\u6765\u5199\uff0c\u770b\u6765\u5b98\u65b9\u4e5f\u4e0d\u60f3\u8ba9\u6211\u4eec\u6765\u7ee7\u627f\u539f\u672c\u7684\u8fd9\u51e0\u4e2a\u57fa\u7840\u52a8\u753b\u554a(\u4e0d\u77e5\u9053\u662f\u4e0d\u662f\u6211\u8fd8\u6ca1\u6709\u627e\u5230\u81ea\u5b9a\u4e49\u52a8\u753b\u7684\u7a8d\u95e8)\u3002\u4e0d\u8fc7\u76ee\u524d\u5c31\u5148\u5b9e\u73b0\u4e00\u4e2a\u518d\u8bf4\uff0c\u5148\u8ffd\u6c42\u6709\uff0c\u518d\u8ffd\u6c42\u597d\u3002\u201c\u7ea2\u7eff\u7ea2\u201d\u786e\u5b9e\u662f\u4e2a\u6bd4\u8f83\u6709\u6548\u548c\u91cd\u8981\u7684\u89c4\u5219\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u516c\u5f0f(&lt;a href=&quot;http:\/\/en.wikipedia.org\/wiki\/B%C3%A9zier_curve&quot; target=&quot;_blank&quot;&gt;\u8c9d\u8332\u66f2\u7dda&lt;\/a&gt;)\u3002\u7b80\u5355\u7684\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u8fd9\u4e2a\u516c\u5f0f\u5728\u56fe\u5f62\u5b66\u4e2d\u975e\u5e38\u6709\u7528\uff0c\u7ebf\u6027\u3001\u4e8c\u6b21\u6216\u8005\u9ad8\u9636\u66f2\u7ebf\u4ee3\u8868\u4e0d\u540c\u7684\u66f2\u7ebf\u7c7b\u522b\uff0c\u6bd4\u5982\u76f4\u7ebf\u3001\u629b\u7269\u7ebf\u6216\u8005\u6ce2\u5f62\u7ebf\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u7528\u4e8c\u9636\u7684\uff0c\u9700\u8981\u6ce8\u610f\u7684\u5c31\u662f\u4e00\u4e2a\u62d0\u70b9\u7684\u95ee\u9898\uff0c\u6211\u4eec\u79f0\u4e3a\u63a7\u5236\u70b9\uff0c\u8fd9\u4e2a\u63a7\u5236\u70b9\u9009\u53d6\u7684\u4e0d\u4e00\u6837\uff0c\u51fa\u6765\u7684\u66f2\u7ebf\u6548\u679c\u5c31\u4e0d\u4e00\u6837\uff0c\u8fd9\u4e2a\u5728\u611f\u6027\u4e0a\u5f88\u5bb9\u6613\u7406\u89e3\u3002&lt;br \/&gt;\n\u5047\u8bbe\u4e09\u4e2a\u70b9P0\u3001P1\u3001P2\uff0c\u516c\u5f0f\u53c2\u7167wiki\u4e8c\u9636\u516c\u5f0f\u3002\u8ba1\u7b97\u7684Java\u4ee3\u7801\u5982\u4e0b&lt;\/p&gt;\n&lt;pre class=&quot;brush: java; title: ; notranslate&quot; title=&quot;&quot;&gt;\tprivate long calcBezier(float interpolatedTime, float p0, float p1, float p2) {\r\n\t\treturn Math.round((Math.pow((1 - interpolatedTime), 2) * p0)\r\n\t\t\t\t+ (2 * (1 - interpolatedTime) * interpolatedTime * p1)\r\n\t\t\t\t+ (Math.pow(interpolatedTime, 2) * p2));\r\n\t}&lt;\/pre&gt;\n&lt;p&gt;\u8fd9\u91cc\u5c31\u662f\u628a\u516c\u5f0f\u8f6c\u5316\u6210\u4e86Java\u4ee3\u7801\uff0c\u6ca1\u6709\u4efb\u4f55\u5176\u5b83\u7684\u52a0\u5de5\u3002\u5b8c\u6574\u7684\u4ee3\u7801\u53c2\u89c1&lt;a href=&quot;https:\/\/gist.github.com\/2293628&quot; target=&quot;_blank&quot;&gt;ArcTranslateAnimation.java&lt;\/a&gt;\uff0c\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\u6211\u4eec\u63a7\u5236\u70b9\u7684\u9009\u62e9\u6bd4\u8f83\u7b80\u5355(mFromXDelta, mToYDelta)\uff0c\u8fd9\u91cc\u6709\u4e2a\u5efa\u8bae\u6216\u8005\u8bf4\u662f\u5e38\u7528\u7684\u5c31\u662f\u901a\u5e38\u7528\u8d77\u70b9\u548c\u7ec8\u70b9\u7684\u5207\u7ebf\u7684\u4ea4\u70b9\u6765\u4f5c\u4e3a\u63a7\u5236\u70b9\uff0c\u5f53\u7136\u63a7\u5236\u70b9\u4f60\u53ef\u4ee5\u81ea\u5df1\u9009\u62e9\uff0c\u6309\u7167\u81ea\u5df1\u7684\u60f3\u6cd5\u7528\u516c\u5f0f\u8ba1\u7b97\u51fa\u6765\u3002&lt;\/p&gt;\n&lt;p&gt;\u5176\u5b83\u7684\u90fd\u6ca1\u6709\u4ec0\u4e48\u9700\u8981\u7279\u522b\u6ce8\u610f\u7684\u5730\u65b9\uff0c\u6309\u7167\u666e\u901a\u7684Animation\u4f7f\u7528\u7684\u65b9\u5f0f\u6765\u4f7f\u7528\u5c31\u53ef\u4ee5\u4e86\u3002\u76ee\u524d\u53ea\u80fd\u901a\u8fc7\u5199Java\u4ee3\u7801\u6765\u4f7f\u7528\u8fd9\u4e2a\u52a8\u753b\uff0c\u5982\u679c\u60f3\u8981\u901a\u8fc7\u914d\u7f6eXML\u6765\u4f7f\u7528\uff0c\u8fd8\u8981\u5b8c\u5584\u8fd9\u4e2a\u7c7b\u7684\u90e8\u5206\u4ee3\u7801\uff0c\u6bd4\u5982\u6dfb\u52a0\u65b0\u7684\u6784\u9020\u51fd\u6570\uff0c\u914d\u7f6e\u5b83\u7684attrs.xml\u7b49\u7b49\uff0c\u53ef\u80fd\u6709\u4e9b\u65b9\u6cd5\u65e0\u6cd5\u4f7f\u7528\u65e2\u6709\u7684\uff0c\u597d\u4e9b\u60f3\u7528\u7684\u65b9\u6cd5\u90fd\u662fprivate\u548cpackage\u3002&lt;\/p&gt;\n&lt;p&gt;\u5927\u5bb6\u5982\u679c\u6709\u4ec0\u4e48\u597d\u7684\u5efa\u8bae\u6216\u8005\u5b9e\u73b0\u65b9\u5f0f\uff0c\u6b22\u8fce\u63d0\u51fa\u6765\uff0cAndroid\u7684UX\u8fd8\u662f\u4e0d\u5982iOS\uff0c\u8981\u4e0d\u7136\u679c\u7c89\u8fd8\u662f\u90a3\u4e48\u591a\u90a3\u4e48\u75af\u72c2\u5462\uff1f&lt;\/p&gt;\n&lt;p&gt;\u54e6\uff0c\u5dee\u70b9\u5fd8\u8bb0\u4e86\uff0c\u8fd8\u8981\u7a0d\u5fae\u63d0\u5230\u4e00\u4e0b\uff0c\u8fd8\u6709\u4e00\u79cd&lt;a href=&quot;http:\/\/developer.android.com\/guide\/topics\/graphics\/drawable-animation.html&quot; target=&quot;_blank&quot;&gt;\u5e27\u52a8\u753b&lt;\/a&gt;\uff0c\u5728Docs\u4e0a\u8fd9\u662f\u88ab\u5217\u5165Android\u652f\u6301\u7684\u4e09\u79cd\u52a8\u753b\u7cfb\u7edf\u4e4b\u4e00\uff0c\u4f46\u4e2a\u4eba\u8ba4\u4e3a\u5e27\u52a8\u753b\u548c\u6e10\u53d8\u52a8\u753b\u8fd9\u662f\u4e24\u79cd\u4e0d\u540c\u7684\u65b9\u5f0f\uff0c\u4ece\u52a8\u753b\u901a\u7528\u7684\u5206\u7c7b\u6765\u8bf4\u53ef\u4ee5\u8fd9\u4e48\u5206\uff0c\u5e76\u4e0d\u9650\u5b9a\u4e8eAndroid\uff0c\u6709\u5174\u8da3\u53ef\u4ee5\u627e\u76f8\u5173\u6750\u6599\u9605\u8bfb\u4e0b\u3002&lt;\/p&gt;\n&lt;p&gt;\u66f4\u591a\u8d44\u6599&lt;br \/&gt;\nhttp:\/\/developer.android.com\/reference\/android\/animation\/package-summary.html&lt;br \/&gt;\nhttp:\/\/developer.android.com\/guide\/topics\/graphics\/animation.html&lt;br \/&gt;\nhttp:\/\/www.math.ubc.ca\/~cass\/gfx\/bezier.html&lt;\/p&gt;\n<\/div><div class=\"gfmr-markdown-rendered\"><p>Android\u652f\u6301\u7684\u52a8\u753b\u7cfb\u7edf\u5927\u4f53\u4e0a\u5206\u4e3a\u4e24\u79cd\uff0c\u5206\u522b\u662f<a href=\"http:\/\/developer.android.com\/guide\/topics\/graphics\/view-animation.html\" target=\"_blank\">View Animation<\/a>\u548c<a href=\"http:\/\/developer.android.com\/guide\/topics\/graphics\/prop-animation.html\" target=\"_blank\">Property Animation<\/a>\uff0c\u603b\u4f53\u6765\u8bf4\u63a8\u8350\u4f7f\u7528Property Animation\uff0cProperty Animation\u66f4\u5f3a\u5927\uff0c\u4f46\u662f\u5982\u679cView Animation\u80fd\u6ee1\u8db3\u4f60\u7684\u9700\u8981\u7684\u8bdd\u6216\u8005\u56e0\u4e3a\u6761\u4ef6\u9650\u5236\u53ea\u80fd\u4f7f\u7528View Animation\uff0c\u90a3\u4e48\u5f53\u7136\u8fd8\u662f\u9009\u62e9View Animation\u3002\u529f\u80fd\u66f4\u591a\u66f4\u5f3a\u5927\u7684\u4e1c\u897f\u610f\u5473\u7740\u4f60\u8981\u4ed8\u51fa\u66f4\u591a\u7684\u52aa\u529b\u6765\u5b9e\u73b0\u548c\u7ef4\u62a4\u5b83\uff0c\u8fd9\u662f\u6e38\u620f\u89c4\u5219\u3002\u95f2\u8bdd\u626f\u8fdc\u4e86\uff0c\u56de\u5230\u4e3b\u9898\uff0c\u8fd8\u6709\u4e00\u70b9\u5c31\u662fProperty Animation\u5728API Level 11\u624d\u5f00\u59cb\u652f\u6301\u3002\u66f4\u591a\u7684\u4ecb\u7ecd\u53ef\u4ee5\u53c2\u770b\u5b98\u65b9\u7684\u6587\u6863\u3002<\/p>\n<p>\u8fd9\u4e24\u79cd\u65b9\u5f0f\u7684\u4f7f\u7528\u90fd\u8fd8\u6bd4\u8f83\u7b80\u5355\u3002\u5728View Animation\u4e2d\u901a\u5e38\u662f\u5b9e\u73b0translate\u3001alpha\u3001scale\u548crotate\u5176\u4e2d\u7684\u4e00\u79cd\u6216\u591a\u79cd(\u5177\u4f53\u7684\u53ef\u4ee5\u901a\u8fc7\u5199\u4ee3\u7801\u6216\u8005\u914d\u7f6eXML\u5b9e\u73b0\uff0c\u5176\u5b9e\u6700\u7ec8\u90fd\u662f\u4e00\u6837\u7684)\u3002\u5728Proerty Animation\u4e2d\u4e5f\u662f\u6307\u5b9a\u8981\u8fdb\u884c\u52a8\u753b\u7684\u5c5e\u6027\uff0c\u6bd4\u5982x\u3001y\u3001alpha\u3001rotation\u6216\u8005scaleX(scaleY)\u7b49\u7b49\u3002\u53c2\u8003docs\u548csamples\u53ef\u4ee5\u5f88\u5feb\u5b9e\u73b0\u57fa\u672c\u52a8\u753b\u3002<\/p>\n<p>\u4f46\u662f\u6709\u65f6\u5019\u6211\u4eec\u9700\u8981\u7684\u6bd4\u8fd9\u4e9b\u57fa\u7840\u529f\u80fd\u8981\u7a0d\u5fae\u590d\u6742\u70b9\u7684\u4e1c\u897f\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u6211\u4eec\u6765\u6269\u5c55\u4e86\u3002\u73b0\u5728\u6211\u4eec\u6765\u5b9e\u73b0\u4e00\u4e2a\u8fd0\u52a8\u8f68\u8ff9\u662f\u66f2\u7ebf\u7684\u52a8\u753b\uff0c\u57fa\u7840\u7684translate\u52a8\u753b\u7684\u8fd0\u52a8\u8f68\u8ff9\u662f\u70b9\u5230\u70b9\u7684\uff0c\u76f4\u7ebf\u7684\u3002<\/p>\n<p>\u5728Property Animation\u4e2d\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003http:\/\/code.google.com\/p\/android-path-animation\/\u8fd9\u4e2a\u4f8b\u5b50\u6765\u5b9e\u73b0\uff0c\u7b80\u5355\u660e\u4e86\u3002\u4f8b\u5b50\u7684\u4f5c\u8005\u4e5f\u662fAndroid Project\u7684Committer\uff0c\u6240\u4ee5\u8fd8\u662f\u5f88\u6709\u5206\u91cf\u7684\u3002<\/p>\n<p>\u5728View Animation\u4e2d\u5c31\u9700\u8981\u81ea\u5df1\u5b9a\u4e49\u4e00\u4e2a\u52a8\u753b\u6765\u5b9e\u73b0\u4e86\uff0cTranslateAnimation\u7684\u8fd0\u52a8\u8f68\u8ff9\u662f\u76f4\u7ebf\uff0c\u65e2\u7136\u6211\u4eec\u9700\u8981\u66f2\u7ebf\u7684\u8f68\u8ff9\uff0c\u90a3\u4e48\u60f3\u5f53\u7136\u6211\u4eec\u53ea\u9700\u8981\u4fee\u6539\u90e8\u5206\u4ee3\u7801\u5c31\u53ef\u4ee5\u4e86\u3002\u539f\u672c\u60f3\u6765\u7ee7\u627fTranslateAnimation\u8fd9\u4e2a\u7c7b\u7684\uff0c\u4f46\u662f\u53d1\u73b0\u8fd9\u4e2a\u7c7b\u91cc\u9762\u6211\u4eec\u9700\u8981\u7684\u53d8\u91cf\u548c\u65b9\u6cd5\u90fd\u662fprivate\u6216\u8005package\uff0c\u6240\u4ee5\u53ea\u597d\u628a\u8fd9\u4e2a\u7c7b\u7684\u4ee3\u7801\u62f7\u8d1d\u4e00\u4efd\u81ea\u5df1\u6765\u5199\uff0c\u770b\u6765\u5b98\u65b9\u4e5f\u4e0d\u60f3\u8ba9\u6211\u4eec\u6765\u7ee7\u627f\u539f\u672c\u7684\u8fd9\u51e0\u4e2a\u57fa\u7840\u52a8\u753b\u554a(\u4e0d\u77e5\u9053\u662f\u4e0d\u662f\u6211\u8fd8\u6ca1\u6709\u627e\u5230\u81ea\u5b9a\u4e49\u52a8\u753b\u7684\u7a8d\u95e8)\u3002\u4e0d\u8fc7\u76ee\u524d\u5c31\u5148\u5b9e\u73b0\u4e00\u4e2a\u518d\u8bf4\uff0c\u5148\u8ffd\u6c42\u6709\uff0c\u518d\u8ffd\u6c42\u597d\u3002\u201c\u7ea2\u7eff\u7ea2\u201d\u786e\u5b9e\u662f\u4e2a\u6bd4\u8f83\u6709\u6548\u548c\u91cd\u8981\u7684\u89c4\u5219\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u516c\u5f0f(<a href=\"http:\/\/en.wikipedia.org\/wiki\/B%C3%A9zier_curve\" target=\"_blank\">\u8c9d\u8332\u66f2\u7dda<\/a>)\u3002\u7b80\u5355\u7684\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u8fd9\u4e2a\u516c\u5f0f\u5728\u56fe\u5f62\u5b66\u4e2d\u975e\u5e38\u6709\u7528\uff0c\u7ebf\u6027\u3001\u4e8c\u6b21\u6216\u8005\u9ad8\u9636\u66f2\u7ebf\u4ee3\u8868\u4e0d\u540c\u7684\u66f2\u7ebf\u7c7b\u522b\uff0c\u6bd4\u5982\u76f4\u7ebf\u3001\u629b\u7269\u7ebf\u6216\u8005\u6ce2\u5f62\u7ebf\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u7528\u4e8c\u9636\u7684\uff0c\u9700\u8981\u6ce8\u610f\u7684\u5c31\u662f\u4e00\u4e2a\u62d0\u70b9\u7684\u95ee\u9898\uff0c\u6211\u4eec\u79f0\u4e3a\u63a7\u5236\u70b9\uff0c\u8fd9\u4e2a\u63a7\u5236\u70b9\u9009\u53d6\u7684\u4e0d\u4e00\u6837\uff0c\u51fa\u6765\u7684\u66f2\u7ebf\u6548\u679c\u5c31\u4e0d\u4e00\u6837\uff0c\u8fd9\u4e2a\u5728\u611f\u6027\u4e0a\u5f88\u5bb9\u6613\u7406\u89e3\u3002<br \/>\n\u5047\u8bbe\u4e09\u4e2a\u70b9P0\u3001P1\u3001P2\uff0c\u516c\u5f0f\u53c2\u7167wiki\u4e8c\u9636\u516c\u5f0f\u3002\u8ba1\u7b97\u7684Java\u4ee3\u7801\u5982\u4e0b<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\tprivate long calcBezier(float interpolatedTime, float p0, float p1, float p2) {\r\n\t\treturn Math.round((Math.pow((1 - interpolatedTime), 2) * p0)\r\n\t\t\t\t+ (2 * (1 - interpolatedTime) * interpolatedTime * p1)\r\n\t\t\t\t+ (Math.pow(interpolatedTime, 2) * p2));\r\n\t}<\/pre>\n<p>\u8fd9\u91cc\u5c31\u662f\u628a\u516c\u5f0f\u8f6c\u5316\u6210\u4e86Java\u4ee3\u7801\uff0c\u6ca1\u6709\u4efb\u4f55\u5176\u5b83\u7684\u52a0\u5de5\u3002\u5b8c\u6574\u7684\u4ee3\u7801\u53c2\u89c1<a href=\"https:\/\/gist.github.com\/2293628\" target=\"_blank\">ArcTranslateAnimation.java<\/a>\uff0c\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\u6211\u4eec\u63a7\u5236\u70b9\u7684\u9009\u62e9\u6bd4\u8f83\u7b80\u5355(mFromXDelta, mToYDelta)\uff0c\u8fd9\u91cc\u6709\u4e2a\u5efa\u8bae\u6216\u8005\u8bf4\u662f\u5e38\u7528\u7684\u5c31\u662f\u901a\u5e38\u7528\u8d77\u70b9\u548c\u7ec8\u70b9\u7684\u5207\u7ebf\u7684\u4ea4\u70b9\u6765\u4f5c\u4e3a\u63a7\u5236\u70b9\uff0c\u5f53\u7136\u63a7\u5236\u70b9\u4f60\u53ef\u4ee5\u81ea\u5df1\u9009\u62e9\uff0c\u6309\u7167\u81ea\u5df1\u7684\u60f3\u6cd5\u7528\u516c\u5f0f\u8ba1\u7b97\u51fa\u6765\u3002<\/p>\n<p>\u5176\u5b83\u7684\u90fd\u6ca1\u6709\u4ec0\u4e48\u9700\u8981\u7279\u522b\u6ce8\u610f\u7684\u5730\u65b9\uff0c\u6309\u7167\u666e\u901a\u7684Animation\u4f7f\u7528\u7684\u65b9\u5f0f\u6765\u4f7f\u7528\u5c31\u53ef\u4ee5\u4e86\u3002\u76ee\u524d\u53ea\u80fd\u901a\u8fc7\u5199Java\u4ee3\u7801\u6765\u4f7f\u7528\u8fd9\u4e2a\u52a8\u753b\uff0c\u5982\u679c\u60f3\u8981\u901a\u8fc7\u914d\u7f6eXML\u6765\u4f7f\u7528\uff0c\u8fd8\u8981\u5b8c\u5584\u8fd9\u4e2a\u7c7b\u7684\u90e8\u5206\u4ee3\u7801\uff0c\u6bd4\u5982\u6dfb\u52a0\u65b0\u7684\u6784\u9020\u51fd\u6570\uff0c\u914d\u7f6e\u5b83\u7684attrs.xml\u7b49\u7b49\uff0c\u53ef\u80fd\u6709\u4e9b\u65b9\u6cd5\u65e0\u6cd5\u4f7f\u7528\u65e2\u6709\u7684\uff0c\u597d\u4e9b\u60f3\u7528\u7684\u65b9\u6cd5\u90fd\u662fprivate\u548cpackage\u3002<\/p>\n<p>\u5927\u5bb6\u5982\u679c\u6709\u4ec0\u4e48\u597d\u7684\u5efa\u8bae\u6216\u8005\u5b9e\u73b0\u65b9\u5f0f\uff0c\u6b22\u8fce\u63d0\u51fa\u6765\uff0cAndroid\u7684UX\u8fd8\u662f\u4e0d\u5982iOS\uff0c\u8981\u4e0d\u7136\u679c\u7c89\u8fd8\u662f\u90a3\u4e48\u591a\u90a3\u4e48\u75af\u72c2\u5462\uff1f<\/p>\n<p>\u54e6\uff0c\u5dee\u70b9\u5fd8\u8bb0\u4e86\uff0c\u8fd8\u8981\u7a0d\u5fae\u63d0\u5230\u4e00\u4e0b\uff0c\u8fd8\u6709\u4e00\u79cd<a href=\"http:\/\/developer.android.com\/guide\/topics\/graphics\/drawable-animation.html\" target=\"_blank\">\u5e27\u52a8\u753b<\/a>\uff0c\u5728Docs\u4e0a\u8fd9\u662f\u88ab\u5217\u5165Android\u652f\u6301\u7684\u4e09\u79cd\u52a8\u753b\u7cfb\u7edf\u4e4b\u4e00\uff0c\u4f46\u4e2a\u4eba\u8ba4\u4e3a\u5e27\u52a8\u753b\u548c\u6e10\u53d8\u52a8\u753b\u8fd9\u662f\u4e24\u79cd\u4e0d\u540c\u7684\u65b9\u5f0f\uff0c\u4ece\u52a8\u753b\u901a\u7528\u7684\u5206\u7c7b\u6765\u8bf4\u53ef\u4ee5\u8fd9\u4e48\u5206\uff0c\u5e76\u4e0d\u9650\u5b9a\u4e8eAndroid\uff0c\u6709\u5174\u8da3\u53ef\u4ee5\u627e\u76f8\u5173\u6750\u6599\u9605\u8bfb\u4e0b\u3002<\/p>\n<p>\u66f4\u591a\u8d44\u6599<br \/>\nhttp:\/\/developer.android.com\/reference\/android\/animation\/package-summary.html<br \/>\nhttp:\/\/developer.android.com\/guide\/topics\/graphics\/animation.html<br \/>\nhttp:\/\/www.math.ubc.ca\/~cass\/gfx\/bezier.html<\/p>\n<\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>&lt;p&gt;Android\u652f\u6301\u7684\u52a8\u753b\u7cfb\u7edf\u5927\u4f53\u4e0a\u5206\u4e3a\u4e24\u79cd\uff0c\u5206\u522b\u662f&lt;a href=&quot;http:\/\/developer.android.com\/guide\/topics\/graphics\/view-animation.html&quot; target=&quot;_blank&quot;&gt;View Animation&lt;\/a&gt;\u548c&lt;a href=&quot;http:\/\/developer.android.com\/guide\/topics\/graphics\/prop-animation.html&quot; target=&quot;_blank&quot;&gt;Property Animation&lt;\/a&gt;\uff0c\u603b\u4f53\u6765\u8bf4\u63a8\u8350\u4f7f\u7528Property Animation\uff0cProperty Animation\u66f4\u5f3a\u5927\uff0c\u4f46\u662f\u5982\u679cView Animation\u80fd\u6ee1\u8db3\u4f60\u7684\u9700\u8981\u7684\u8bdd\u6216\u8005\u56e0\u4e3a\u6761\u4ef6\u9650\u5236\u53ea\u80fd\u4f7f\u7528View Animation\uff0c\u90a3\u4e48\u5f53\u7136\u8fd8\u662f\u9009\u62e9View Animation\u3002\u529f\u80fd\u66f4\u591a\u66f4\u5f3a\u5927\u7684\u4e1c\u897f\u610f\u5473\u7740\u4f60\u8981\u4ed8\u51fa\u66f4\u591a\u7684\u52aa\u529b\u6765\u5b9e\u73b0\u548c\u7ef4\u62a4\u5b83\uff0c\u8fd9\u662f\u6e38\u620f\u89c4\u5219\u3002\u95f2\u8bdd\u626f\u8fdc\u4e86\uff0c\u56de\u5230\u4e3b\u9898\uff0c\u8fd8\u6709\u4e00\u70b9\u5c31\u662fProperty Animation\u5728API Level 11\u624d\u5f00\u59cb\u652f\u6301\u3002\u66f4\u591a\u7684\u4ecb\u7ecd\u53ef\u4ee5\u53c2\u770b\u5b98\u65b9\u7684\u6587\u6863\u3002&lt;\/p&gt; &lt;p&gt;\u8fd9\u4e24\u79cd\u65b9\u5f0f\u7684\u4f7f\u7528\u90fd\u8fd8\u6bd4\u8f83\u7b80\u5355\u3002\u5728View Animation\u4e2d\u901a\u5e38\u662f\u5b9e\u73b0translate\u3001alpha\u3001scale\u548crotate\u5176\u4e2d\u7684\u4e00\u79cd\u6216\u591a\u79cd(\u5177\u4f53\u7684\u53ef\u4ee5\u901a\u8fc7\u5199\u4ee3\u7801\u6216\u8005\u914d\u7f6eXML\u5b9e\u73b0\uff0c\u5176\u5b9e\u6700\u7ec8\u90fd\u662f\u4e00\u6837\u7684)\u3002\u5728Proerty Animation\u4e2d\u4e5f\u662f\u6307\u5b9a\u8981\u8fdb\u884c\u52a8\u753b\u7684\u5c5e\u6027\uff0c\u6bd4\u5982x\u3001y\u3001alpha\u3001rotation\u6216\u8005scaleX(scaleY)\u7b49\u7b49\u3002\u53c2\u8003docs\u548csamples\u53ef\u4ee5\u5f88\u5feb\u5b9e\u73b0\u57fa\u672c\u52a8\u753b\u3002&lt;\/p&gt; &lt;p&gt;\u4f46\u662f\u6709\u65f6\u5019\u6211\u4eec\u9700\u8981\u7684\u6bd4\u8fd9\u4e9b\u57fa\u7840\u529f\u80fd\u8981\u7a0d\u5fae\u590d\u6742\u70b9\u7684\u4e1c\u897f\uff0c\u90a3\u4e48\u5c31\u9700\u8981\u6211\u4eec\u6765\u6269\u5c55\u4e86\u3002\u73b0\u5728\u6211\u4eec\u6765\u5b9e\u73b0\u4e00\u4e2a\u8fd0\u52a8\u8f68\u8ff9\u662f\u66f2\u7ebf\u7684\u52a8\u753b\uff0c\u57fa\u7840\u7684translate\u52a8\u753b\u7684\u8fd0\u52a8\u8f68\u8ff9\u662f\u70b9\u5230\u70b9\u7684\uff0c\u76f4\u7ebf\u7684\u3002&lt;\/p&gt; &lt;p&gt;\u5728Property Animation\u4e2d\u5927\u5bb6\u53ef\u4ee5\u53c2\u8003http:\/\/code.google.com\/p\/android-path-animation\/\u8fd9\u4e2a\u4f8b\u5b50\u6765\u5b9e\u73b0\uff0c\u7b80\u5355\u660e\u4e86\u3002\u4f8b\u5b50\u7684\u4f5c\u8005\u4e5f\u662fAndroid Project\u7684Committer\uff0c\u6240\u4ee5\u8fd8\u662f\u5f88\u6709\u5206\u91cf\u7684\u3002&lt;\/p&gt; &lt;p&gt;\u5728View Animation\u4e2d\u5c31\u9700\u8981\u81ea\u5df1\u5b9a\u4e49\u4e00\u4e2a\u52a8\u753b\u6765\u5b9e\u73b0\u4e86\uff0cTranslateAnimation\u7684\u8fd0\u52a8\u8f68\u8ff9\u662f\u76f4\u7ebf\uff0c\u65e2\u7136\u6211\u4eec\u9700\u8981\u66f2\u7ebf\u7684\u8f68\u8ff9\uff0c\u90a3\u4e48\u60f3\u5f53\u7136\u6211\u4eec\u53ea\u9700\u8981\u4fee\u6539\u90e8\u5206\u4ee3\u7801\u5c31\u53ef\u4ee5\u4e86\u3002\u539f\u672c\u60f3\u6765\u7ee7\u627fTranslateAnimation\u8fd9\u4e2a\u7c7b\u7684\uff0c\u4f46\u662f\u53d1\u73b0\u8fd9\u4e2a\u7c7b\u91cc\u9762\u6211\u4eec\u9700\u8981\u7684\u53d8\u91cf\u548c\u65b9\u6cd5\u90fd\u662fprivate\u6216\u8005package\uff0c\u6240\u4ee5\u53ea\u597d\u628a\u8fd9\u4e2a\u7c7b\u7684\u4ee3\u7801\u62f7\u8d1d\u4e00\u4efd\u81ea\u5df1\u6765\u5199\uff0c\u770b\u6765\u5b98\u65b9\u4e5f\u4e0d\u60f3\u8ba9\u6211\u4eec\u6765\u7ee7\u627f\u539f\u672c\u7684\u8fd9\u51e0\u4e2a\u57fa\u7840\u52a8\u753b\u554a(\u4e0d\u77e5\u9053\u662f\u4e0d\u662f\u6211\u8fd8\u6ca1\u6709\u627e\u5230\u81ea\u5b9a\u4e49\u52a8\u753b\u7684\u7a8d\u95e8)\u3002\u4e0d\u8fc7\u76ee\u524d\u5c31\u5148\u5b9e\u73b0\u4e00\u4e2a\u518d\u8bf4\uff0c\u5148\u8ffd\u6c42\u6709\uff0c\u518d\u8ffd\u6c42\u597d\u3002\u201c\u7ea2\u7eff\u7ea2\u201d\u786e\u5b9e\u662f\u4e2a\u6bd4\u8f83\u6709\u6548\u548c\u91cd\u8981\u7684\u89c4\u5219\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u9700\u8981\u4e00\u4e2a\u516c\u5f0f(&lt;a href=&quot;http:\/\/en.wikipedia.org\/wiki\/B%C3%A9zier_curve&quot; target=&quot;_blank&quot;&gt;\u8c9d\u8332\u66f2\u7dda&lt;\/a&gt;)\u3002\u7b80\u5355\u7684\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u8fd9\u4e2a\u516c\u5f0f\u5728\u56fe\u5f62\u5b66\u4e2d\u975e\u5e38\u6709\u7528\uff0c\u7ebf\u6027\u3001\u4e8c\u6b21\u6216\u8005\u9ad8\u9636\u66f2\u7ebf\u4ee3\u8868\u4e0d\u540c\u7684\u66f2\u7ebf\u7c7b\u522b\uff0c\u6bd4\u5982\u76f4\u7ebf\u3001\u629b\u7269\u7ebf\u6216\u8005\u6ce2\u5f62\u7ebf\u3002\u5728\u8fd9\u91cc\u6211\u4eec\u7528\u4e8c\u9636\u7684\uff0c\u9700\u8981\u6ce8\u610f\u7684\u5c31\u662f\u4e00\u4e2a\u62d0\u70b9\u7684\u95ee\u9898\uff0c\u6211\u4eec\u79f0\u4e3a\u63a7\u5236\u70b9\uff0c\u8fd9\u4e2a\u63a7\u5236\u70b9\u9009\u53d6\u7684\u4e0d\u4e00\u6837\uff0c\u51fa\u6765\u7684\u66f2\u7ebf\u6548\u679c\u5c31\u4e0d\u4e00\u6837\uff0c\u8fd9\u4e2a\u5728\u611f\u6027\u4e0a\u5f88\u5bb9\u6613\u7406\u89e3\u3002&lt;br \/&gt; \u5047\u8bbe\u4e09\u4e2a\u70b9P0\u3001P1\u3001P2\uff0c\u516c\u5f0f\u53c2\u7167wiki\u4e8c\u9636\u516c\u5f0f\u3002\u8ba1\u7b97\u7684Java\u4ee3\u7801\u5982\u4e0b&lt;\/p&gt; &lt;pre class=&quot;brush: java; title: ; notranslate&quot; title=&quot;&quot;&gt; private long calcBezier(float interpolatedTime, float p0, float p1, float p2) { return Math.round((Math.pow((1 &#8211; interpolatedTime), 2) * p0) + (2 &hellip; <a href=\"https:\/\/guoh.ai\/lifelog\/2012\/04\/android-customized-curved-path-animation\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Android\u81ea\u5b9a\u4e49\u52a8\u753b\u4e4b\u66f2\u7ebf\u8f68\u8ff9<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gfmr_meta_descriptions":[],"_gfmr_multilingual_taxonomy_terms":[],"footnotes":""},"categories":[7],"tags":[25],"class_list":["post-411","post","type-post","status-publish","format-standard","hentry","category-android","tag-animation"],"_links":{"self":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/comments?post=411"}],"version-history":[{"count":6,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/411\/revisions"}],"predecessor-version":[{"id":416,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/411\/revisions\/416"}],"wp:attachment":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/media?parent=411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/categories?post=411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/tags?post=411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}