
{"id":288,"date":"2016-04-19T09:36:08","date_gmt":"2016-04-19T01:36:08","guid":{"rendered":"http:\/\/www.jiandaima.com\/blog\/?p=288"},"modified":"2016-12-05T14:58:08","modified_gmt":"2016-12-05T06:58:08","slug":"%e5%b8%a6%e6%9c%89%e9%98%bb%e5%b0%bc%e6%95%88%e6%9e%9c%ef%bc%88%e6%a9%a1%e7%9a%ae%e7%ad%8b%e6%95%88%e6%9e%9c%ef%bc%89%e8%b7%b3%e5%8a%a8%e7%9a%84loading%e5%8a%a8%e7%94%bb","status":"publish","type":"post","link":"http:\/\/www.jiandaima.com\/blog\/archives\/288.html","title":{"rendered":"\u5e26\u6709\u963b\u5c3c\u6548\u679c\uff08\u6a61\u76ae\u7b4b\u6548\u679c\uff09\u8df3\u52a8\u7684Loading\u52a8\u753b"},"content":{"rendered":"<blockquote><p>\u4e4b\u524d\u516c\u53f8\u9700\u8981\u6211\u7b49\u7a0b\u5e8f\u5458\u5de6\u53f3\u4e00\u4e2a\u7279\u6b8a\u7684loading\u6548\u679c\uff0c\u6211\u4eec\u7684APP\u662f\u751f\u9c9cO2O\u7684\u67d0\u516c\u53f8\uff0c\u5c06\u539f\u6765listview\u7684\u4e0b\u62c9loading\u52a8\u753b\u66f4\u6362\u6210\u4e00\u4e2a\u5e26\u6709\u963b\u5c3c\u6548\u679c\u4e5f\u5c31\u662f\u6a61\u76ae\u7b4b\u6548\u679c\u7684loading\u5177\u4f53\u7684\u5c31\u662f\u6c34\u679c\u5f80\u4e0b\u7838\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4e0b\u9762\u7684\u6587\u5b57\u4f1a\u5f2f\u66f2\uff0c\u4f1a\u628a\u6c34\u679c\u539f\u5c01\u4e0d\u52a8\u7684\u5f39\u56de\u4e0a\u9762\u3002\u52a8\u624b\u4e4b\u524d\u89c9\u5f97\u8fd9\u4e2a\u6548\u679c\u5f88\u96be\uff0c\u52a8\u753b\u6548\u679c\u592a\u4e30\u5bcc\uff0c\u5bf9\u4e8e\u6587\u5b57\u7684\u5f2f\u66f2\u5f39\u56de\u6548\u679c\u51e0\u4e4e\u662f\u675f\u624b\u65e0\u7b56\uff0c\u540e\u6765\u7ecf\u8fc7\u540c\u4e8b\u7684\u70b9\u62e8\uff0c\u6709\u4e86\u4e00\u4e2a\u5927\u6982\u7684\u65b9\u5411\u3002<\/p><\/blockquote>\n<p>\u5e76\u6700\u7ec8\u5b9e\u73b0\u4e86\u5148\u770b\u4e00\u4e2a\u5927\u6982\u7684\u6548\u679c\u56fe\uff1a<\/p>\n<p><a href=\"https:\/\/www.jiandaima.com\/blog\/wp-content\/uploads\/2016\/04\/0.gif\" class=\"highslide-image\" onclick=\"return hs.expand(this);\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-289\" src=\"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/04\/0-157x260.gif?imageView2\/1\/w\/314\/h\/520#\" alt=\"0\" width=\"157\" height=\"260\" \/><\/a><\/p>\n<p>\u5b9e\u73b0\u601d\u8def\u5982\u4e0b\uff1a<\/p>\n<p>1    \u81f3\u4e8e\u600e\u4e48\u53bb\u5b9e\u73b0\u6587\u5b57\u5f2f\u66f2\u7684\u6548\u679c\uff0c\u6211\u4e4b\u524d\u60f3\u8fc7\u6587\u5b57\u7528\u5207\u56fe\uff0c\u7136\u540e\u7528\u626d\u66f2\u5207\u56fe\u7684\u65b9\u5f0f\u6765\u5b9e\u73b0\u6587\u5b57\u5f2f\u66f2\uff0c\u7ed3\u679c\u53d1\u73b0\u8fd9\u4e2a\u505a\u6cd5\u8fc7\u4e8e\u590d\u6742\u4e14\u6700\u7ec8\u6548\u679c\u4e0d\u592a\u597d\uff0c\u6240\u4ee5\u7ecf\u8fc7\u540c\u4e8b\u63d0\u9192\u4f7f\u7528\u4e86\u53e6\u5916\u4e00\u79cd\u505a\u6cd5\uff0c\u5229\u7528Path\u8def\u5f84\u6765\u505a\uff0c\u901a\u8fc7\u5b9e\u65f6\u7684\u53d8\u5316Path\u8def\u5f84\u6765\u5b9e\u73b0\u52a8\u753b\u6548\u679c\uff0c\u540c\u65f6\u5e94\u7528canvas.drawTextOnPath\u7684\u65b9\u6cd5\u53ef\u4ee5\u8ba9\u6587\u5b57\u6839\u636ePath\u8def\u5f84\u6765\u7ed8\u5236\uff0c\u8fd9\u6837\u5c31\u5b9e\u73b0\u4e86\u6587\u5b57\u7684\u5f2f\u66f2\u6548\u679c<\/p>\n<p>2 \u6c34\u679c\u52a8\u753b\u52a0\u901f\u7684\u6548\u679c\uff0c\u8fd9\u4e2a\u5c31\u6bd4\u8f83\u7b80\u5355\uff0c\u5229\u7528animation\u539f\u751f\u7684\u52a0\u901f\u5668\u5373\u53ef\u5b9e\u73b0\uff0c\u4e0a\u4e0b\u5750\u6807\u79fb\u52a8\uff0c\u4e14\u7ed5\u81ea\u8eab\u65cb\u8f6c\uff0c\u8fd9\u91cc\u6211\u4eec\u7528AnimationSet\u96c6\u5408\u628aRotateAnimation\u548cTranslateAnimation\u540c\u65f6\u5e94\u7528\uff0c\u5e76\u4e14\u5728TranslatAnimtion\u7684\u7ed3\u675f\u7684\u65f6\u5019\u66f4\u6362view\u7684\u56fe\u7247\uff0c\u8fbe\u5230\u7838\u4e2d\u6587\u5b57\u7684\u65f6\u5019\u56fe\u7247\u7acb\u523b\u66f4\u6362\u7684\u6548\u679c\uff0c\u6c34\u679c\u7684\u56fe\u7247\u8981\u653e\u5728\u4e00\u4e2a\u56fa\u5b9a\u7684\u6570\u7ec4\u91cc\u9762<\/p>\n<p>3\u4e3a\u4e86\u5b9e\u73b0\u52a8\u753b\u7684\u5e73\u6ed1\u8fc7\u6e21\uff0c\u8fd9\u91cc\u8981\u6c42\u79fb\u52a8\u52a8\u753b\u548cRotateAnimation\u7684\u901f\u5ea6\u4e00\u81f4\uff0cRotateAnimation\u7ed5360\u5ea6\u7684\u7ed3\u675f\u7684\u65f6\u5019\u6b63\u597d\u662fTranslateAnimation\u4ece\u4e0a\u5230\u4e0b\u7684\u8fc7\u7a0b\uff0c\u5426\u5219\u52a8\u753b\u5c31\u4f1a\u5f88\u751f\u786c\uff0c\u4f53\u9a8c\u53ef\u4ee5\u6539DEMO\u91cc\u9762\u7684\u6570\u503c\u6765\u4f53\u9a8c<\/p>\n<p>4 \u8fd8\u6709\u4e00\u70b9\u8981\u6ce8\u610f\uff0ccanvas.drawText\u7684\u65b9\u6cd5\u7684Y\u5750\u6807\u5e76\u4e0d\u662f\u6307\u753b\u6587\u5b57\u7684\u5de6\u4e0a\u89d2\u7684\u5750\u6807\uff0c\u800c\u662f\u6587\u5b57\u7684baseline\u7684\u5750\u6807\uff0c\u81f3\u4e8e\u4ec0\u4e48\u4e8bbaseline\uff0c\u8bf7\u767e\u5ea6<\/p>\n<p>5\u672c\u4f8b\u6700\u5927\u7684\u96be\u70b9\u8fd8\u662f\u6587\u5b57\u5f2f\u66f2\u7684\u6548\u679c\uff0c\u5176\u4e2d\u4e00\u5f00\u59cb\u9700\u8981\u753b\u7684\u662f\u76f4\u7ebf\uff0c\u7b49\u5230animationEnd\u7684\u65f6\u5019\u6211\u4eec\u8981\u8ba9\u6587\u5b57\u5f00\u59cb\u5f2f\u66f2\uff0c\u5f2f\u66f2\u7684\u8fc7\u7a0b\u4e2d\u8981\u8bbe\u7f6e\u4e00\u4e2a\u53d8\u91cf\uff0c\u53d8\u91cf\u6bcf\u6b21\u90fd\u5728\u589e\u957f\uff0c\u5f2f\u66f2\u7684\u7a0b\u5ea6\u4f1a\u8d8a\u6765\u8d8a\u5927\uff0c\u5e76\u4e14\u8981\u8bbe\u7f6e\u4e00\u4e2a\u5c01\u9876\u503c\uff0c\u5230\u4e86MAX\u4e4b\u540e\u4fbf\u8981\u5f80\u56de\u6536\u7f29\uff0c\u6587\u5b57\u5f2f\u66f2\u7684\u65f6\u5019\u8fd8\u8981\u8bbe\u7f6e\u4e09\u79cd\u72b6\u6001\uff0c\u5e73\u76f4\u72b6\u6001\uff0c\u5411\u4e0b\u5f2f\u66f2\u8fc7\u7a0b\u4e2d\u7684\u72b6\u6001\u4ee5\u53ca\u5f80\u56de\u6536\u7f29\u7684\u72b6\u6001\uff0c\u5e76\u4e14\u4f60\u7684\u53d8\u91cf\u503c\u8981\u6839\u636e\u5f53\u524d\u662f\u4f55\u79cd\u72b6\u6001\u6765\u51b3\u5b9a\u53d8\u91cf\u662f\u7ee7\u7eed\u589e\u5927\u8fd8\u662f\u51cf\u5c0f\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n \/**\r\n     * \u753b\u51fa\u76f4\u7ebf\u7684\u6587\u5b57\r\n     *\r\n     * @param canvas\r\n     *\/\r\n    void drawLinePathAndText(Canvas canvas) {\r\n        if (mPath == null) {\r\n            mPath = new Path();\r\n            drawLinePath();\r\n        } else {\r\n            drawArcPath();\r\n            mRecfSpace = getRecfSpace();\r\n            if (mRecfSpace &gt;= MAX_RECF_SPACE){\r\n                mCurveStatus = STATUS_UP_CURVE;\r\n            }else if (mRecfSpace &lt;= MIN_RECF_SPACE){\r\n                mCurveStatus = STATUS_DOWN_CURVE;\r\n            }\r\n\r\n        }\r\n        if (mSringCount&lt;MAX_SPRING_COUNT){\r\n            mSringCount++;\r\n            invalidate();\r\n        }else reset(canvas);\r\n        canvas.drawTextOnPath(mResText, mPath, 0, 0, mTextPaint);\r\n    }\r\n<\/pre>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n  \/**\r\n     * \u753b\u51fa\u5f27\u7ebf\u8def\u5f84\r\n     *\/\r\n    void drawArcPath() {\r\n        mPath.reset();\/\/        RectF rectF = new RectF(0, PAINT_TEXT_BASEIINE, mTextWidth, PAINT_TEXT_BASEIINE + mRecfSpace);\/\/        mPath.addOval(rectF, Path.Direction.CCW);\r\n        mPath.moveTo(0, PAINT_TEXT_BASEIINE); \/\/\u8bbe\u5b9a\u8d77\u59cb\u70b9\/\/        mPath.lineTo(mTextWidth\/5,PAINT_TEXT_BASEIINE);\r\n        mPath.quadTo(0,PAINT_TEXT_BASEIINE,5,PAINT_TEXT_BASEIINE);\r\n        mPath.quadTo(mTextWidth\/2,PAINT_TEXT_BASEIINE + mRecfSpace,mTextWidth-5,PAINT_TEXT_BASEIINE);\r\n        mPath.quadTo(mTextWidth*5\/6,PAINT_TEXT_BASEIINE,mTextWidth,PAINT_TEXT_BASEIINE);\r\n        mPath.close();\r\n    }\r\n\r\n<\/pre>\n<p>6\u6700\u540e\u4e00\u4e2a\u96be\u70b9\u5c31\u662f\u5f27\u7ebf\u7684\u7ed8\u5236\uff0c\u4e00\u5f00\u59cb\u7528\u7684\u662f\u6839\u636erect \u6765drawArc\uff0c\u8fd9\u79cd\u65b9\u6cd5\u6839\u636erect\u77e9\u5f62\u4e2d\u7684\u5305\u542b\u7684\u6700\u5927\u7684\u692d\u5706\u5f62\uff0c\u4ece\u692d\u5706\u5f62\u7684\u53f3\u4fa7\u7ed8\u5236\u5230\u5de6\u4fa7\u5f62\u6210\u4e00\u4e2a\u89c4\u5219\u7684\u5f27\u7ebf\uff0c\u540e\u6765\u770b\u8fd9\u79cd\u6548\u679c\u7528\u5728\u8fd9\u91cc\u5e76\u4e0d\u597d\uff0c\u540e\u6765\u5728\u7f51\u4e0a\u53d1\u73b0\u4e86path.quadTO\u65b9\u6cd5\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u9ed8\u8ba4\u662f\u7ed8\u5236\u4e00\u6761\u76f4\u7ebf\uff0c\u4f46\u662f\u4ed6\u53ef\u4ee5\u518d\u524d\u9762\u4e24\u4e2a\u53c2\u6570\u8bbe\u7f6e\u4e00\u4e2aXY\u5750\u6807\uff0c\u76f8\u5f53\u4e8e\u4eba\u7684\u624b\u628a\u8fd9\u6761\u76f4\u7ebf\u7684\u67d0\u4e2a\u70b9\u62c9\u5230\u4e86XY\u8fd9\u4e2a\u5750\u6807\u7684\u4f4d\u7f6e\uff0c \u4ece\u800c\u5b9e\u73b0\u4e86\u5f27\u7ebf\u7684\u6548\u679c\uff0c\u5f27\u7ebf\u7684\u5927\u5c0f\u5c31\u53d6\u51b3\u4e8e\u8fd9\u4e2aY\u503c\u3002Y\u503c\u8d8a\u5927\uff0c\u7b49\u4e8e\u8fd9\u4e2a\u4eba\u628a\u8fd9\u6761\u7ebf\u62c9\u7684\u8d8a\u72e0\uff0c\u5f2f\u66f2\u7a0b\u5ea6\u81ea\u7136\u8d8a\u5927\u3002\u4e0d\u8bf4\u4e86\uff0c\u770b\u4ee3\u7801\u5427\u3002<\/p>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u5e26\u6709\u963b\u5c3c\u6548\u679c\uff08\u6a61\u76ae\u7b4b\u6548\u679c\uff09\u8df3\u52a8\u7684Loading\u52a8\u753b<\/p>\n","protected":false},"author":1,"featured_media":522,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[73],"class_list":["post-288","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-the-development-of-communication-technology","tag-loading"],"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":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/04\/0-e1461029737497.gif","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":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/04\/0-e1461029737497.gif","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":"http:\/\/images.jiandaima.com\/blog\/wp-content\/uploads\/2016\/04\/0-157x260.gif?imageView2\/1\/w\/314\/h\/520#","id":"image0"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":5,"total_comments":0,"category_name":"\u5f00\u53d1\u6280\u672f\u4ea4\u6d41","post_date":"2016-04-19","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":625,"next_post_id":294,"next_post_title":"\u5173\u4e8e Android \u8fdb\u7a0b\u4fdd\u6d3b\uff0c\u4f60\u6240\u9700\u8981\u77e5\u9053\u7684\u4e00\u5207","previous_post_id":270,"previous_post_title":"\u57fa\u4e8eHTTP2\u7684\u5168\u65b0APNs\u534f\u8bae","_links":{"self":[{"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/posts\/288","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=288"}],"version-history":[{"count":0,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/posts\/288\/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=288"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/categories?post=288"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jiandaima.com\/blog\/wp-json\/wp\/v2\/tags?post=288"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}