
{"id":785,"date":"2016-11-14T10:55:16","date_gmt":"2016-11-14T02:55:16","guid":{"rendered":"http:\/\/www.jiandaima.com\/blog\/?p=785"},"modified":"2016-11-14T11:12:03","modified_gmt":"2016-11-14T03:12:03","slug":"android%e5%9f%ba%e7%a1%80%e5%8a%a8%e7%94%bb%e7%bb%84%e5%90%88%e5%8a%a8%e7%94%bb%ef%bc%8c%e5%b8%a7%e5%8a%a8%e7%94%bb%ef%bc%8c%e5%b8%83%e5%b1%80%e5%8a%a8%e7%94%bb%ef%bc%8cactivity%e8%b7%b3%e8%bd%ac","status":"publish","type":"post","link":"http:\/\/www.jiandaima.com\/blog\/archives\/785.html","title":{"rendered":"Android\u57fa\u7840\u52a8\u753b,\u7ec4\u5408\u52a8\u753b\uff0c\u5e27\u52a8\u753b\uff0c\u5e03\u5c40\u52a8\u753b\uff0cActivity\u8df3\u8f6c\u52a8\u753b \u6e90\u7801\u4e0b\u8f7d"},"content":{"rendered":"<p>    Android\u4e2d\u5e38\u7528\u7684\u52a8\u753b\u90fd\u5728\u8fd9\u91cc\u4e86\uff0c\u5305\u542b\u4e86\u57fa\u672c\u7684\u52a8\u753b\u3010\u900f\u660e\u5ea6\u52a8\u753b\uff0c\u7f29\u653e\u52a8\u753b\uff0c\u65cb\u8f6c\u52a8\u753b\uff0c\u4f4d\u79fb\u52a8\u753b\u3011\uff1b\u8fd8\u6709\u5c31\u662f\u8fd9\u56db\u79cd\u52a8\u753b\u7684\u7ec4\u5408\u5b9e\u73b0\uff1b \u8fd8\u6709\u5e03\u5c40\u52a8\u753b\uff0c\u5c31\u662f\u5728\u52a0\u8f7d\u5e03\u5c40\u65f6\u7684\u52a8\u753b\uff1b\u8fd8\u6709Activity\u8df3\u8f6c\u7684\u52a8\u753b\u3002 \u6548\u679c\u56fe\u5982\u4e0b\uff1a<\/p>\n<p><a href=\"https:\/\/github.com\/linglongxin24\/AnimationDemo\/raw\/master\/screenshorts\/effect.gif?raw=true\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/github.com\/linglongxin24\/AnimationDemo\/raw\/master\/screenshorts\/effect.gif?raw=true\" width=\"340\" height=\"605\" alt=\"\" class=\"aligncenter size-medium\" \/><\/a><\/p>\n<p>1. Android\u57fa\u7840\u52a8\u753b<\/p>\n<p>\u900f\u660e\u5ea6\u52a8\u753b<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\r\n &lt;set xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;&gt;\r\n     &lt;alpha\r\n         android:duration=&quot;1000&quot;\r\n         android:fromAlpha=&quot;0.0&quot;\r\n         android:toAlpha=&quot;1.0&quot;\r\n         \/&gt;\r\n &lt;\/set&gt;\r\n<\/pre>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\r\n   \/**\r\n    * \u7b2c\u4e00\u4e2a\u53c2\u6570fromAlpha\u4e3a \u52a8\u753b\u5f00\u59cb\u65f6\u5019\u900f\u660e\u5ea6\r\n    *\u7b2c\u4e8c\u4e2a\u53c2\u6570toAlpha\u4e3a \u52a8\u753b\u7ed3\u675f\u65f6\u5019\u900f\u660e\u5ea6\r\n     *\/\r\n     Animation animation = new AlphaAnimation(0, 1);\r\n     animation.setDuration(1000);\r\n    v.startAnimation(animation);\r\n<\/pre>\n<p>\u7f29\u653e\u52a8\u753b<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\r\n&lt;set xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;&gt;\r\n    &lt;scale\r\n        android:duration=&quot;1000&quot;\r\n        android:fromXScale=&quot;0&quot;\r\n        android:fromYScale=&quot;0&quot;\r\n        android:pivotX=&quot;50%&quot;\r\n        android:pivotY=&quot;50%&quot;\r\n        android:toXScale=&quot;1&quot;\r\n        android:toYScale=&quot;1&quot; \/&gt;\r\n&lt;\/set&gt;\r\n\r\n<\/pre>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\r\n \/**\r\n * \u7b2c\u4e00\u4e2a\u53c2\u6570fromX\u4e3a\u52a8\u753b\u8d77\u59cb\u65f6 X\u5750\u6807\u4e0a\u7684\u4f38\u7f29\u5c3a\u5bf8\r\n * \u7b2c\u4e8c\u4e2a\u53c2\u6570toX\u4e3a\u52a8\u753b\u7ed3\u675f\u65f6 X\u5750\u6807\u4e0a\u7684\u4f38\u7f29\u5c3a\u5bf8\r\n * \u7b2c\u4e09\u4e2a\u53c2\u6570fromY\u4e3a\u52a8\u753b\u8d77\u59cb\u65f6Y\u5750\u6807\u4e0a\u7684\u4f38\u7f29\u5c3a\u5bf8\r\n * \u7b2c\u56db\u4e2a\u53c2\u6570toY\u4e3a\u52a8\u753b\u7ed3\u675f\u65f6Y\u5750\u6807\u4e0a\u7684\u4f38\u7f29\u5c3a\u5bf8\r\n * \u8bf4\u660e: 0.0\u8868\u793a\u6536\u7f29\u5230\u6ca1\u6709;1.0\u8868\u793a\u6b63\u5e38\u65e0\u4f38\u7f29;\u503c\u5c0f\u4e8e1.0\u8868\u793a\u6536\u7f29;\u503c\u5927\u4e8e1.\r\n * \u7b2c\u4e94\u4e2a\u53c2\u6570pivotXType\u4e3a\u52a8\u753b\u5728X\u8f74\u76f8\u5bf9\u4e8e\u7269\u4ef6\u4f4d\u7f6e\u7c7b\u578b\r\n * \u7b2c\u516d\u4e2a\u53c2\u6570pivotXValue\u4e3a\u52a8\u753b\u76f8\u5bf9\u4e8e\u7269\u4ef6\u7684X\u5750\u6807\u7684\u5f00\u59cb\u4f4d\u7f6e\r\n * \u7b2c\u4e03\u4e2a\u53c2\u6570pivotXType\u4e3a\u52a8\u753b\u5728Y\u8f74\u76f8\u5bf9\u4e8e\u7269\u4ef6\u4f4d\u7f6e\u7c7b\u578b\r\n * \u7b2c\u516b\u4e2a\u53c2\u6570pivotYValue\u4e3a\u52a8\u753b\u76f8\u5bf9\u4e8e\u7269\u4ef6\u7684Y\u5750\u6807\u7684\u5f00\u59cb\u4f4d\u7f6e\r\n *\/\r\nAnimation animation = new ScaleAnimation(0, 1\r\nanimation.setDuration(1000);\r\niv.startAnimation(animation);\r\n\r\n<\/pre>\n<p>\u65cb\u8f6c\u52a8\u753b<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\r\n&lt;set xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;&gt;\r\n    &lt;rotate\r\n        android:duration=&quot;1000&quot;\r\n        android:fromDegrees=&quot;0&quot;\r\n        android:pivotX=&quot;50%&quot;\r\n        android:pivotY=&quot;50%&quot;\r\n        android:toDegrees=&quot;360&quot; \/&gt;\r\n&lt;\/set&gt;\r\n\r\n<\/pre>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\r\n    \/**\r\n     * \u7b2c\u4e00\u4e2a\u53c2\u6570fromDegrees\u4e3a\u52a8\u753b\u8d77\u59cb\u65f6\u89d2\u5ea6\r\n     * \u7b2c\u4e8c\u4e2a\u53c2\u6570toDegrees\u4e3a\u52a8\u753b\u7ed3\u675f\u89d2\u5ea6\r\n     * \u7b2c\u4e09\u4e2a\u53c2\u6570pivotXType\u4e3a\u52a8\u753b\u5728X\u8f74\u76f8\u5bf9\u4e8e\u7269\u4ef6\u4f4d\u7f6e\u7c7b\u578b\r\n     * \u7b2c\u56db\u4e2a\u53c2\u6570pivotXValue\u4e3a\u52a8\u753b\u76f8\u5bf9\u4e8e\u7269\u4ef6\u7684X\u5750\u6807\u7684\u5f00\u59cb\u4f4d\u7f6e\r\n     * \u7b2c\u4e94\u4e2a\u53c2\u6570pivotXType\u4e3a\u52a8\u753b\u5728Y\u8f74\u76f8\u5bf9\u4e8e\u7269\u4ef6\u4f4d\u7f6e\u7c7b\u578b\r\n     * \u7b2c\u516d\u4e2a\u53c2\u6570pivotYValue\u4e3a\u52a8\u753b\u76f8\u5bf9\u4e8e\u7269\u4ef6\u7684Y\u5750\u6807\u7684\u5f00\u59cb\u4f4d\u7f6e\r\n     *\/\r\n    Animation animation = new RotateAnima\r\n    animation.setDuration(1000);\r\n    iv.startAnimation(animation);\r\n\r\n<\/pre>\n<p>\u4f4d\u79fb\u52a8\u753b<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\r\n&lt;set xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;&gt;\r\n    &lt;translate\r\n        android:duration=&quot;2000&quot;\r\n        android:fromXDelta=&quot;0&quot;\r\n        android:fromYDelta=&quot;0&quot;\r\n        android:toXDelta=&quot;500&quot;\r\n        android:interpolator=&quot;@android:anim\/accelerate_interpolator&quot;\r\n        android:toYDelta=&quot;0&quot; \/&gt;\r\n&lt;\/set&gt;\r\n\r\n<\/pre>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n    \/**\r\n     * \u7b2c\u4e00\u4e2a\u53c2\u6570fromDegrees\u4e3a\u52a8\u753b\u8d77\u59cb\u65f6\u89d2\u5ea6\r\n     * \u7b2c\u4e8c\u4e2a\u53c2\u6570toDegrees\u4e3a\u52a8\u753b\u7ed3\u675f\u89d2\u5ea6\r\n     * \u7b2c\u4e09\u4e2a\u53c2\u6570pivotXType\u4e3a\u52a8\u753b\u5728X\u8f74\u76f8\u5bf9\u4e8e\u7269\u4ef6\u4f4d\u7f6e\u7c7b\u578b\r\n     * \u7b2c\u56db\u4e2a\u53c2\u6570pivotXValue\u4e3a\u52a8\u753b\u76f8\u5bf9\u4e8e\u7269\u4ef6\u7684X\u5750\u6807\u7684\u5f00\u59cb\u4f4d\u7f6e\r\n     * \u7b2c\u4e94\u4e2a\u53c2\u6570pivotXType\u4e3a\u52a8\u753b\u5728Y\u8f74\u76f8\u5bf9\u4e8e\u7269\u4ef6\u4f4d\u7f6e\u7c7b\u578b\r\n     * \u7b2c\u516d\u4e2a\u53c2\u6570pivotYValue\u4e3a\u52a8\u753b\u76f8\u5bf9\u4e8e\u7269\u4ef6\u7684Y\u5750\u6807\u7684\u5f00\u59cb\u4f4d\u7f6e\r\n     *\/\r\n     Animation animation = new RotateAnima\r\n     animation.setDuration(1000);\r\n     iv.startAnimation(animation);\r\n     \/**\r\n      * \u7b2c\u4e00\u4e2a\u53c2\u6570fromXDelta\u4e3a\u52a8\u753b\u8d77\u59cb\u65f6\u7684x\u5750\u6807\r\n      * \u7b2c\u4e8c\u4e2a\u53c2\u6570toXDelta\u4e3a\u52a8\u753b\u7ed3\u675f\u65f6\u7684x\u5750\u6807\r\n      * \u7b2c\u4e09\u4e2a\u53c2\u6570fromYDelta\u4e3a\u52a8\u753b\u8d77\u59cb\u65f6\u7684y\u5750\u6807\r\n      * \u7b2c\u56db\u4e2a\u53c2\u6570toYDelta\u4e3a\u52a8\u753b\u7ed3\u675f\u65f6\u7684y\u5750\u6807\r\n      *\/\r\n      Animation animation = new Translat\r\n      animation.setDuration(2000);\r\n      \/**\u8bbe\u7f6e\u63d2\u503c\u5668\uff1a\u5148\u52a0\u901f\uff0c\u540e\u51cf\u901f**\/\r\n      animation.setInterpolator(new Acce\r\n      iv.startAnimation(animation);\r\n<\/pre>\n<p>2.\u7ec4\u5408\u52a8\u753b<br \/>\n\u5148\u64ad\u653e\u7f29\u653e\u52a8\u753b\uff0c\u5b8c\u6210\u540e\u64ad\u653e\u65cb\u8f6c\u52a8\u753b<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\r\n Animation animation = AnimationUtils.loadAnimation(this, R.anim.scale);\r\n              iv.startAnimation(animation);\r\n              final Animation animation2 = AnimationUtils.loadAnimation(this, R.anim.rotate);\r\n              animation.setAnimationListener(new Animation.AnimationListener() {\r\n                  @Override\r\n                  public void onAnimationStart(Animation animation) {\r\n\r\n                  }\r\n\r\n                  @Override\r\n                  public void onAnimationEnd(Animation animation) {\r\n\r\n                      iv.startAnimation(animation2);\r\n                  }\r\n\r\n                  @Override\r\n                  public void onAnimationRepeat(Animation animation) {\r\n\r\n                  }\r\n              });\r\n\r\n<\/pre>\n<p>\u5148\u64ad\u653e\u65cb\u8f6c\u52a8\u753b\uff0c\u5b8c\u6210\u540e\u64ad\u653e\u4f4d\u79fb\u52a8\u753b\uff0c\u5728xml\u4e2d\u8bbe\u7f6e\u7b2c\u4e8c\u4e2a\u52a8\u753b\u6267\u884c\u7684\u7b49\u5f85\u65f6\u95f4<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\r\n&lt;set xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;&gt;\r\n\r\n    &lt;rotate\r\n        android:duration=&quot;1000&quot;\r\n        android:fromDegrees=&quot;0&quot;\r\n        android:pivotX=&quot;50%&quot;\r\n        android:pivotY=&quot;50%&quot;\r\n        android:toDegrees=&quot;360&quot; \/&gt;\r\n    &lt;translate\r\n        android:duration=&quot;1000&quot;\r\n        android:fromXDelta=&quot;0&quot;\r\n        android:fromYDelta=&quot;0&quot;\r\n        android:toXDelta=&quot;500&quot;\r\n        android:startOffset=&quot;1000&quot;\r\n        android:interpolator=&quot;@android:anim\/accelerate_interpolator&quot;\r\n        android:toYDelta=&quot;0&quot; \/&gt;\r\n&lt;\/set&gt;\r\n<\/pre>\n<p>\u91cd\u590d\u7684\u900f\u660e\u5ea6\u52a8\u753b-\u95ea\u70c1<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\nAlphaAnimation alphaAnimation = new AlphaAnimation(0.1f, 1.0f);\r\n                alphaAnimation.setDuration(1000);\r\n                alphaAnimation.setRepeatCount(10);\r\n                \/**\u5012\u5e8f\u91cd\u590dREVERSE  \u6b63\u5e8f\u91cd\u590dRESTART**\/\r\n                alphaAnimation.setRepeatMode(Animation.REVERSE);\r\n                iv.startAnimation(alphaAnimation);\r\n<\/pre>\n<p>\u91cd\u590d\u7684\u4f4d\u79fb\u52a8\u753b-\u6296\u52a8<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n Animation translateAnimation = new TranslateAnimation(-10, 10, 0, 0);\r\n                translateAnimation.setDuration(100);\r\n                translateAnimation.setRepeatCount(10);\r\n                \/**\u5012\u5e8f\u91cd\u590dREVERSE  \u6b63\u5e8f\u91cd\u590dRESTART**\/\r\n                translateAnimation.setRepeatMode(Animation.REVERSE);\r\n                iv.startAnimation(translateAnimation);\r\n<\/pre>\n<p>3.\u5e27\u52a8\u753b<\/p>\n<p>\u66f4\u591a\u52a8\u753b\u6e90\u7801\u6837\u5f0f\uff0c\u4e0b\u8f7d\u6e90\u7801\u67e5\u770b<\/p>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>Android\u57fa\u7840\u52a8\u753b,\u7ec4\u5408\u52a8\u753b\uff0c\u5e27\u52a8\u753b\uff0c\u5e03\u5c40\u52a8\u753b\uff0cActivity\u8df3\u8f6c\u52a8\u753b \u6e90\u7801\u4e0b\u8f7d\uff0c\u5305\u542b\u4e86\u57fa\u672c\u7684\u52a8\u753b\u3010\u900f\u660e\u5ea6\u52a8\u753b\uff0c\u7f29\u653e\u52a8\u753b\uff0c\u65cb\u8f6c\u52a8\u753b\uff0c\u4f4d\u79fb\u52a8\u753b\u3011\uff1b\u8fd8\u6709\u5c31\u662f\u8fd9\u56db\u79cd\u52a8\u753b\u7684\u7ec4\u5408\u5b9e\u73b0\uff1b \u8fd8\u6709\u5e03\u5c40\u52a8\u753b\uff0c\u5c31\u662f\u5728\u52a0\u8f7d\u5e03\u5c40\u65f6\u7684\u52a8\u753b\uff1b\u8fd8\u6709Activity\u8df3\u8f6c\u7684\u52a8\u753b<\/p>\n","protected":false},"author":1,"featured_media":522,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[231,18,230,19],"class_list":["post-785","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-application-source-code","tag-activity","tag-android"],"post_thumbnail_image":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/05\/64022-3.png?imageView2\/1\/w\/300\/h\/300#","content_first_image":"https:\/\/github.com\/linglongxin24\/AnimationDemo\/raw\/master\/screenshorts\/effect.gif?raw=true","post_medium_image_300":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/05\/64022-3.png?imageView2\/1\/w\/600\/h\/356#","post_thumbnail_image_624":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/05\/64022-3.png","post_frist_image":"https:\/\/github.com\/linglongxin24\/AnimationDemo\/raw\/master\/screenshorts\/effect.gif?raw=true","post_medium_image":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/05\/64022-3.png?imageView2\/1\/w\/600\/h\/356#","post_large_image":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/05\/64022-3.png","post_full_image":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/05\/64022-3.png","post_all_images":[{"imagesurl":"https:\/\/github.com\/linglongxin24\/AnimationDemo\/raw\/master\/screenshorts\/effect.gif?raw=true","id":"image0"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":5,"total_comments":0,"category_name":"\u5e94\u7528\u7a0b\u5e8f\u6e90\u7801","post_date":"2016-11-14","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2020\/02\/img_5e44112722964.png","avatarurls":[],"related_posts":[],"pageviews":659,"next_post_id":793,"next_post_title":"[\u5b89\u5353,android\u6e90\u7801] \u7b80\u8bd7Android \u6e90\u7801\uff0cPython \u548c Flask\u670d\u52a1\u5668\u7aef\u540e\u53f0\u6e90\u7801\u4e0b\u8f7d","previous_post_id":776,"previous_post_title":"[ios\u6e90\u7801] \u4eff\u95f2\u9c7c\u4e8c\u624b\u4ea4\u6613\u5e73\u53f0-iOS\u6e90\u7801-\u6361\u4ee3\u7801\u8bba\u575b","_links":{"self":[{"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/posts\/785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/comments?post=785"}],"version-history":[{"count":0,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/posts\/785\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/media\/522"}],"wp:attachment":[{"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/media?parent=785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/categories?post=785"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/tags?post=785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}