{"id":1245,"date":"2016-02-17T14:55:09","date_gmt":"2016-02-17T06:55:09","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=1245"},"modified":"2026-08-18T12:58:48","modified_gmt":"2026-08-18T04:58:48","slug":"android%e5%b9%bf%e5%91%8a%e6%a0%8f%e5%ae%9e%e7%8e%b0%e8%bf%87%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=1245","title":{"rendered":"Android\u5e7f\u544a\u680f\u5b9e\u73b0\u8fc7\u7a0b"},"content":{"rendered":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<blockquote style=\"margin: 20px 0px; display: block; font-size: 0.9em; overflow: auto; border-left: 3px solid #ef7060; color: #6a737d; padding: 10px 10px 10px 20px; background: #fff9f9;\">\n<p style=\"margin: 1em 0px;\">\u5e7f\u544a\u680f\u8f6e\u5b50\u5f88\u597d\u627e\uff0c\u4f46\u5b8c\u5168\u5408\u7528\u7684\u5e76\u4e0d\u591a\uff1a\u6709\u7684\u7ed1\u6b7b Picasso \u5403\u5185\u5b58\uff0c\u6709\u7684\u5c11\u4e8e\u4e09\u9875\u5c31\u629b\u5f02\u5e38\u3002\u672c\u7bc7\u4ece ViewPager \u8d77\u6b65\uff0c\u4e00\u6b65\u6b65\u8865\u4e0a\u65e0\u9650\u8f6e\u64ad\u3001\u5207\u6362\u901f\u5ea6\u3001\u81ea\u52a8\u64ad\u653e\u3001\u6307\u793a\u5668\u548c\u70b9\u51fb\u56de\u8c03\uff0c\u9020\u4e00\u4e2a\u591f\u7528\u7684 Banner\u3002<\/p>\n<\/blockquote>\n<p><!--more--><\/p>\n<p style=\"margin: 1em 0px;\">\u5f00\u6e90\u754c\u6709\u4e00\u53e5\u5f88\u6709\u540d\u7684\u8bdd\u53eb\u201c\u4e0d\u8981\u91cd\u590d\u53d1\u660e\u8f6e\u5b50\u201d\uff0c\u5f53\u7136\uff0c\u6211\u4eca\u5929\u7684\u89c2\u70b9\u4e0d\u662f\u8981\u53cd\u9a73\u8fd9\u53e5\u8bdd\uff0c\u8f6e\u5b50\u7406\u8bba\u7ed9\u6211\u4eec\u7684\u5f00\u53d1\u5e26\u6765\u4e86\u6781\u5927\u7684\u4fbf\u5229\uff0c\u9879\u76ee\u4e2d\u8981\u5b9e\u73b0\u4e00\u4e9b\u529f\u80fd\uff0c\u4fbf\u53bb\u7f51\u4e0a\u627e\u627e\uff0c\u4e00\u822c\u63a8\u8350\u4f7f\u7528\u4e00\u4e9b\u6709\u540d\u7684\u5e93\uff0c\u6211\u672c\u8eab\u4e5f\u662f\u8fd9\u4e48\u505a\u7684\uff0c\u4f46\u6211\u60f3\u8bf4\u7684\u662f\uff0c\u65e2\u8981\u4f1a\u7528\u8f6e\u5b50\uff0c\u4e5f\u8981\u77e5\u9053\u8f6e\u5b50\u600e\u4e48\u9020\uff0c\u5fc5\u8981\u7684\u65f6\u5019\uff0c\u81ea\u5df1\u4e5f\u8981\u9020\u8f6e\u5b50\uff08\u60f3\u8981\u627e\u5230\u4e00\u4e2a\u5b8c\u5168\u6ee1\u610f\u7684\u8f6e\u5b50\u8fd8\u662f\u4e0d\u5927\u5bb9\u6613\u7684\uff09\u3002<\/p>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u7531\u6765<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u4e4b\u524d\u9879\u76ee\u91cc\u9762\u90fd\u662f\u7528\u7684daimajia\u7684<a href=\"https:\/\/github.com\/daimajia\/AndroidImageSlider\" target=\"_blank\">AndroidImageSlider<\/a>,<\/p>\n<p style=\"margin: 1em 0px;\"><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2016\/02\/baner1.gif\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1288\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2016\/02\/baner1.gif\" alt=\"baner1\" width=\"329\" height=\"560\" \/><\/a><\/p>\n<p style=\"margin: 1em 0px;\">\u4e00\u5f00\u59cb\u88ab\u60ca\u8273\u7684\u52a8\u753b\u5207\u6362\u6548\u679c\u5438\u5f15\u4e86\uff0c\u8fd8\u6709\u5404\u79cd\u81ea\u5b9a\u4e49\u5c5e\u6027\u52a8\u753b\u5565\u7684\uff0c\u611f\u89c9\u5f88\u68d2\uff0c\u4f46\u968f\u7740\u9879\u76ee\u7684\u8fdb\u5c55\u548c\u65f6\u95f4\u7684\u63a8\u79fb\uff0c\u6211\u6162\u6162\u53d1\u73b0\u5b83\u4e5f\u4e0d\u662f\u65e0\u6240\u4e0d\u80fd\u7684\uff0c\u751a\u81f3\u6211\u53d1\u73b0\u5b83\u53ea\u662f\u597d\u770b\uff0c\u5374\u4e0d\u600e\u4e48\u5b9e\u7528\uff0c\u6211\u5217\u4e3e\u4e00\u4e9b\u6211\u53d1\u73b0\u7684\u95ee\u9898\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u5e93\u4e2d\u96c6\u6210\u4e86Picasso\uff0cPicasso\u662f\u6781\u5176\u8017\u5185\u5b58\u7684\uff0c\u8fd9\u70b9\u6211\u5728\u4e4b\u524d\u7684\u4e00\u7bc7<a href=\"http:\/\/blog.csdn.net\/djk_dong\/article\/details\/47702191\" target=\"_blank\">\u4e3a\u4ec0\u4e48\u56fe\u7247\u52a0\u8f7d\u6211\u9996\u5148Glide <\/a>\u63d0\u5230\u8fc7\uff0c\u5f53\u4e00\u4e2a\u9875\u9762\u65e2\u6709\u5e7f\u544a\u53c8\u6709\u5217\u8868\uff08\u5217\u8868\u4e2d\u4e5f\u4e00\u822c\u6709\u56fe\u7247\uff09\u4f1a\u9020\u6210\u9875\u9762\u4e25\u91cd\u5361\u987f\u3002<\/section>\n<\/li>\n<li>\n<section>\u52a8\u753b\u6548\u679c\u592a\u70ab\uff0c\u5b9e\u9645\u9879\u76ee\u4e2d\u4e00\u4e2a\u6ca1\u7528\u5230\uff0c\u4e00\u822c\u7528\u6807\u51c6\u6a21\u5f0f\u3002<\/section>\n<\/li>\n<li>\n<section>\u592a\u591a\u7684\u4f9d\u8d56\u5305\uff0c\u73b0\u5728\u7684\u8bb8\u591a\u9879\u76ee\u90fd\u662f\u57fa\u4e8eandroid4.0\u4ee5\u4e0a\u7248\u672c\u5f00\u53d1\u7684\uff0cnineoldandroid\u5df2\u7ecf\u4e0d\u9700\u8981\u4e86<\/section>\n<\/li>\n<li>\n<section>\u9875\u9762\u70b9\u51fb\u4e8b\u4ef6\u4e0d\u76f4\u89c2\uff0c\u5982\u679c\u6709\u90a3\u79cd\u50cfListView\u7684OnItemClickListener\u5c31\u597d\u4e86<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u603b\u800c\u8a00\u4e4b\uff0c\u6211\u611f\u89c9\u5b83\u73b0\u5728\u5df2\u7ecf\u6709\u4e9b\u81c3\u80bf\u3002\u5f53\u7136\uff0c\u6211\u4e5f\u5728\u7f51\u4e0a\u5bfb\u627e\u66f4\u7b80\u6d01\u5b9e\u7528\u7684\u66ff\u4ee3\u5e93\uff0c\u6bd4\u5982<a href=\"https:\/\/github.com\/bingoogolapple\/BGABanner-Android\" target=\"_blank\">BGABanner-Android<\/a>,\u4f46\u4e8b\u5b9e\u4e5f\u662f\u6b8b\u9177\u7684\uff0c\u4e0d\u652f\u6301\u7f51\u7edc\u56fe\u7247\uff0c\u8fd8\u6709\u4e00\u4e2a\u5751\u7b49\u7740\u6211\u8df3\uff0c\u770b\u4ee3\u7801\u7247\u6bb5<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">if (mAutoPlayAble &amp;&amp; views.size() &lt; 3) { \n\n       throw new IllegalArgumentException(\"\u5f00\u542f\u6307\u5b9a\u8f6e\u64ad\u65f6\u81f3\u5c11\u6709\u4e09\u4e2a\u9875\u9762\"); \n\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4f4e\u4e8e3\u5f20\u56fe\u7247\u4f1a\u76f4\u63a5\u629b\u5f02\u5e38\uff0c\u8fd9\u53eb\u6211\u600e\u4e48\u7528\uff0c\u9700\u6c42\u4e5f\u4e0d\u662f\u6211\u80fd\u63a7\u5236\u7684\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u5f53\u7136\u4ee5\u4e0a\u4e24\u4e2a\u5e93\u7684\u4f5c\u8005\u6211\u90fd\u5f88\u559c\u6b22\uff0c\u8fd9\u4e24\u4e2a\u5e93\u4e5f\u975e\u5e38\u4e0d\u9519\uff0c\u4e0d\u7136\u4e5f\u4e0d\u503c\u5f97\u6211\u82b1\u65f6\u95f4\u7814\u7a76\u3002<\/p>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u6211\u5bf9\u8f6e\u5b50\u7684\u8981\u6c42<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u7ed3\u5408\u81ea\u5df1\u7684\u7406\u89e3\uff0c\u6211\u8ba4\u4e3a\u4e24\u4e2a\u5e93\u4e2d\u90fd\u6709\u53ef\u53d6\u4e4b\u5904\uff0c\u4e5f\u6709\u4e0d\u8db3\u4e4b\u5904\uff0c\u6211\u5c31\u53d6\u957f\u8865\u77ed\uff0c\u9020\u81ea\u5df1\u7684\u8f6e\u5b50\uff0c\u6211\u5bf9\u8fd9\u4e2a\u8f6e\u5b50\u7684\u8981\u6c42\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u65e0\u9650\u8f6e\u64ad<\/section>\n<\/li>\n<li>\n<section>\u81ea\u52a8\u52a0\u624b\u52a8\u6ed1\u52a8<\/section>\n<\/li>\n<li>\n<section>\u7b80\u5355\u7684\u81ea\u5b9a\u4e49\u6307\u793a\u5668\u6837\u5f0f\u53ca\u4f4d\u7f6e<\/section>\n<\/li>\n<li>\n<section>\u652f\u6301\u672c\u5730\u56fe\u7247\u53ca\u7f51\u7edc\u56fe\u7247<\/section>\n<\/li>\n<li>\n<section>\u6ed1\u52a8\u6d41\u7545\uff0c\u65e0\u5361\u987f\uff0c\u65e0\u95ea\u70c1<\/section>\n<\/li>\n<li>\n<section>\u5e7f\u544a\u9875\u9762\u4e0d\u9650\u5236\u4e2a\u6570<\/section>\n<\/li>\n<li>\n<section>\u9875\u9762\u70b9\u51fb\u76d1\u542c\u4e8b\u4ef6<\/section>\n<\/li>\n<li>\n<section>\u7b80\u5355\u6613\u7528\uff0c\u9ad8\u914d\u7f6e\uff0c\u65e0\u660e\u663ebug<\/p>\n<p>\u52a8\u753b\u6548\u679c\u6211\u5148\u6253\u7b97\u629b\u5f03\u4e86\uff0c\u9ed8\u8ba4\u7684\u5c31\u597d\uff0c\u4ee5\u5b9e\u7528\u4e3a\u4e3b\u3002<\/section>\n<\/li>\n<\/ul>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u5f00\u59cb\u52a8\u624b\uff0cstep by step<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u7cfb\u7edf\u53ef\u4ee5\u6ed1\u52a8\u7ffb\u9875\u7684\u63a7\u4ef6\u5c31\u53ea\u6709ViewPager\u548cViewFliper\u7f51\u4e0a\u8fd8\u6709\u5927\u795e\u5b9e\u73b0\u7528RecyclerView\u5b9e\u73b0\u4e86\u7c7b\u4f3cViewPager\u7684\u6548\u679c\uff0c\u8fd9\u91cc\u6682\u4e0d\u505a\u8fc7\u591a\u7814\u7a76\uff0c\u8fd9\u91cc\u5c31\u9009\u62e9\u4f7f\u7528\u6700\u591aViewPager\u4f5c\u4e3a\u6ed1\u52a8\u7ffb\u9875\u63a7\u4ef6\uff0c\u4f7f\u7528ViewPager+PagerAdapter\u53ef\u4ee5\u5f88\u5bb9\u6613\u7684\u5b9e\u73b0\u7ffb\u9875\u5207\u6362\u6548\u679c\uff0c\u4f46\u5b58\u5728\u51e0\u4e2a\u5f0a\u7aef\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u4e0d\u80fd\u65e0\u9650\u8f6e\u56de\u7684\u7ffb\u9875\uff08\u6ed1\u5230\u7b2c\u4e00\u4e2a\u6216\u8005\u6700\u540e\u4e00\u4e2a\u5c31\u4e0d\u80fd\u7ee7\u7eed\u6ed1\uff09<\/section>\n<\/li>\n<li>\n<section>\u5207\u6362\u901f\u5ea6\u592a\u5feb\uff0c\u7cfb\u7edf\u9ed8\u8ba4250\u6beb\u79d2\uff0c\u7528\u505a\u5e7f\u544a\u680f\u5207\u6362\u4f1a\u5b58\u5728\u660e\u663e\u95ea\u70c1<\/section>\n<\/li>\n<li>\n<section>\u4ec5\u652f\u6301\u624b\u52a8\u6ed1\u52a8\uff0c\u4e0d\u652f\u6301\u81ea\u52a8\u5207\u6362<\/section>\n<\/li>\n<li>\n<section>\u6ca1\u6709\u63d0\u4f9b\u76f4\u63a5\u7684\u7c7b\u4f3cListView\u7684OnItemClickListener\u76d1\u542c\uff0c\u4f7f\u7528\u8d77\u6765\u5f88\u4e0d\u65b9\u4fbf<\/p>\n<p>\u5f53\u7136\u8fd8\u4f1a\u6709\u5176\u4ed6\u7684\u5751\uff0c\u9047\u5230\u4e86\u518d\u89e3\u51b3\uff0c\u5148\u89e3\u51b3\u4e0a\u9762\u7684\u95ee\u9898<\/section>\n<\/li>\n<\/ul>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u65e0\u9650\u8f6e\u64ad\u6548\u679c<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u8fd9\u91cc\u91c7\u7528\u7f51\u4e0a\u901a\u7528\u7684\u89e3\u51b3\u529e\u6cd5\uff0c\u4f2a\u8f6e\u64ad\uff08\u8ba9\u7528\u6237\u770b\u5230\u8f6e\u64ad\u7684\u5047\u8c61\uff0c\u5b9e\u9645\u4e0a\u7528\u4e86\u5f88\u591a\u9875\u9762\u5728\u4e0d\u65ad\u91cd\u590d\u51fa\u73b0\uff0c\u5982\u679c\u7528\u6237\u6ed1\u52a8\u51e0\u5341\u4ebf\u4e0b\u662f\u53ef\u4ee5\u6ed1\u5230\u5934\uff0c\u5b9e\u9645\u51e0\u4e4e\u4e0d\u53ef\u80fd\u6709\u4eba\u8fd9\u4e48\u505a\uff09\u770b\u5177\u4f53\u5b9e\u73b0\u4ee3\u7801<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">  public class LoopPagerAdapter extends PagerAdapter {\n\n        private List&lt;View&gt; views;\n\n        public LoopPagerAdapter(List&lt;View&gt; views) {\n\n            this.views = views;\n\n        }\n\n        @Override\n\n        public int getCount() {\n\n            \/\/Integer.MAX_VALUE = 2147483647\n\n            return Integer.MAX_VALUE;\n\n        }\n\n        @Override\n\n        public boolean isViewFromObject(View view, Object object) {\n\n            return view == object;\n\n        }\n\n        @Override\n\n        public Object instantiateItem(ViewGroup container, int position) {\n\n            if (views.size() &gt; 0) {\n\n                \/\/position % view.size()\u662f\u6307\u865a\u62df\u7684position\u4f1a\u5728[0\uff0cview.size()\uff09\u4e4b\u95f4\u5faa\u73af\n\n                View view = views.get(position % views.size());\n\n                if (container.equals(view.getParent())) {\n\n                    container.removeView(view);\n\n                }\n\n                container.addView(view);\n\n                return view;\n\n            }\n\n            return null;\n\n        }\n\n        @Override\n\n        public void destroyItem(ViewGroup container, int position, Object object) {\n\n        }\n\n    }<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u8fd8\u9700\u8981\u505a\u4e00\u4ef6\u4e8b\u60c5\uff0c\u5c31\u662f\u8bbe\u7f6e\u5f53\u524dposition\u4e3a\u4e2d\u95f4\u7684\u4e00\u4e2a\u8f83\u5927\u7684\u503c\uff0c\u5982\u679c\u4e0d\u8bbe\u7f6e\u6216\u8005\u8bbe\u7f6e\u7684\u6bd4\u8f83\u5c0f\uff0c\u5f80\u5de6\u6ed1\u52a8\u5bb9\u6613\u6ed1\u5012\u5934<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">pager.setCurrentItem(Integer.MAX_VALUE \/ 2 - Integer.MAX_VALUE \/ 2 % views.size());<\/code><\/pre>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u6539\u53d8\u539f\u751fViewPager\u5207\u6362\u901f\u5ea6<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u901a\u8fc7\u53cd\u5c04\u62ff\u5230ViewPager\u7684\u6ed1\u52a8\u5668mScroller\uff0c\u6539\u53d8duration\u53c2\u6570\uff0c\u770b\u4ee3\u7801\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\"> public void setSliderTransformDuration(int duration) {\n\n        try {\n\n            Field mScroller = ViewPager.class.getDeclaredField(\"mScroller\");\n\n            mScroller.setAccessible(true);\n\n            FixedSpeedScroller scroller = new FixedSpeedScroller(pager.getContext(), null, duration);\n\n            mScroller.set(pager, scroller);\n\n        } catch (Exception e) {\n\n        }\n\n    }\n\n\/\/FixedSpeedScroller.java\n\npublic class FixedSpeedScroller extends Scroller {\n\n   \/\/\u9ed8\u8ba41\u79d2\uff0c\u53ef\u4ee5\u901a\u8fc7\u4e0a\u9762\u7684\u65b9\u6cd5\u63a7\u5236\n\n    private int mDuration = 1000;\n\n    public FixedSpeedScroller(Context context) {\n\n        super(context);\n\n    }\n\n    public FixedSpeedScroller(Context context, Interpolator interpolator) {\n\n        super(context, interpolator);\n\n    }\n\n    public FixedSpeedScroller(Context context, Interpolator interpolator, int duration){\n\n        this(context,interpolator);\n\n        mDuration = duration;\n\n    }\n\n    @Override\n\n    public void startScroll(int startX, int startY, int dx, int dy, int duration) {\n\n        \/\/ Ignore received duration, use fixed one instead\n\n        super.startScroll(startX, startY, dx, dy, mDuration);\n\n    }\n\n    @Override\n\n    public void startScroll(int startX, int startY, int dx, int dy) {\n\n        \/\/ Ignore received duration, use fixed one instead\n\n        super.startScroll(startX, startY, dx, dy, mDuration);\n\n    }\n\n}<\/code><\/pre>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u81ea\u52a8\u5207\u6362\u5b9e\u73b0<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u8fd9\u91cc\u53ef\u4ee5\u6709\u591a\u79cd\u65b9\u5f0f\uff0c\u4f7f\u7528Handler\u6216\u8005Timer\u90fd\u53ef\u4ee5\u7684\uff0c\u8fd9\u91cc\u91c7\u7528handler\u5b9e\u73b0\uff0cisAutoPlay\u53ef\u4ee5\u63a7\u5236\u662f\u5426\u7981\u6b62\u63a7\u4ef6\u81ea\u52a8\u8f6e\u64ad\uff0cautoPlayDuration\u662f\u8f6e\u64ad\u95f4\u9694\u65f6\u95f4\uff0c\u8fd8\u9700\u6ce8\u610f\u89e6\u6478\u65f6\u5e94\u5f53\u505c\u6b62\u8f6e\u64ad\uff0c\u653e\u5f00\u6062\u590d\u6b63\u5e38<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\/**\n\n     * \u5f00\u59cb\u81ea\u52a8\u8f6e\u64ad\n\n     *\/\n\n    public void startAutoPlay() {\n\n        if (isAutoPlay) {\n\n            handler.sendEmptyMessageDelayed(WHAT_AUTO_PLAY, autoPlayDuration);\n\n        }\n\n    }\n\n    \/**\n\n     * \u505c\u6b62\u81ea\u52a8\u8f6e\u64ad\n\n     *\/\n\n    public void stopAutoPlay() {\n\n        if (isAutoPlay) {\n\n            handler.removeMessages(WHAT_AUTO_PLAY);\n\n        }\n\n    }\n\n    @Override\n\n    public boolean dispatchTouchEvent(MotionEvent ev) {\n\n        switch (ev.getAction()) {\n\n            case MotionEvent.ACTION_DOWN:\n\n                stopAutoPlay();\n\n                break;\n\n            case MotionEvent.ACTION_CANCEL:\n\n            case MotionEvent.ACTION_UP:\n\n                startAutoPlay();\n\n                break;\n\n        }\n\n        return super.dispatchTouchEvent(ev);\n\n    }<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u5148\u9644\u4e0a\u4e00\u5f20\u9884\u89c8\u56fe\uff1a<\/p>\n<p style=\"margin: 1em 0px;\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/ww4.sinaimg.cn\/large\/0064cTs2jw1f067jehqitg30b705tnkh.gif\" alt=\"\" width=\"403\" height=\"209\" \/><\/p>\n<p style=\"margin: 1em 0px;\">\u5148\u5199\u8fd9\u4e48\u591a\u5427\uff0c\u540e\u7eed\u5b8c\u6574\u4ee3\u7801\u6211\u4f1a\u4e0a\u4f20\u5230github\uff0c\u5982\u679c\u5927\u5bb6\u6709\u5174\u8da3\uff0c\u6211\u4f1a\u62bd\u65f6\u95f4\u5199\u5269\u4e0b\u7684\u5185\u5bb9\uff0c\u8fd9\u4e2a\u63a7\u4ef6\u7684\u4ee3\u7801\u4e5f\u662f\u501f\u9274\u4e86\u5f88\u591a\u4f18\u79c0\u7684\u5f00\u6e90\u5e93\uff0c\u5e76\u7ed3\u5408\u81ea\u5df1\u7684\u7406\u89e3\u5199\u7684\u3002<\/p>\n<blockquote style=\"margin: 20px 0px; display: block; font-size: 0.9em; overflow: auto; border-left: 3px solid #ef7060; color: #6a737d; padding: 10px 10px 10px 20px; background: #fff9f9;\">\n<p style=\"margin: 1em 0px;\">\u70ab\u4e3d\u7684\u6548\u679c\u56fa\u7136\u5438\u5f15\u4eba\u773c\u7403\uff0c\u5e73\u51e1\u5b9e\u7528\u7684\u4e1c\u897f\u624d\u6108\u4e45\u5f25\u9999<\/p>\n<\/blockquote>\n<p style=\"margin: 1em 0px;\">\u5b8c\u6574\u4ee3\u7801\u5df2\u4e0a\u4f20\u5230github:<a href=\"https:\/\/github.com\/dongjunkun\/BannerLayoutDemo\" target=\"_blank\">BannerLayoutDemo<\/a><\/p>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u6dfb\u52a0\u6307\u793a\u5668\u2013\u7ed8\u5236\u6307\u793a\u5668\u6837\u5f0f<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">github\u4e0a\u4e5f\u6709\u5404\u79cd\u5404\u6837\u5f88\u68d2\u7684\u6307\u793a\u5668\uff0c\u53ef\u4f5c\u4e3a\u72ec\u7acb\u63a7\u4ef6\uff0c\u8fd9\u91cc\u6211\u5148\u7b80\u5355\u5904\u7406\u76f4\u63a5\u96c6\u6210\u5230\u5185\u90e8\uff0c\u540e\u671f\u6709\u9700\u6c42\u518d\u8fdb\u884c\u91cd\u6784\uff0c\u6700\u7b80\u5355\u7684\u6307\u793a\u5668\u662f\u7528\u4e24\u5f20\u4e0d\u540c\u72b6\u6001\u7684\u5c0f\u56fe\u7247\u505a\u7684\uff0c\u4f46\u6211\u8ba4\u4e3a\u8fd9\u6837\u505a\u76f8\u5bf9\u5b9e\u73b0\u662f\u7b80\u5355\u7684\uff0c\u4f46\u5bf9\u4e8e\u4fee\u6539\u5374\u663e\u5f97\u6709\u4e9b\u9ebb\u70e6\uff0c\u9002\u914d\u4e5f\u662f\u95ee\u9898\uff0c\u7b80\u5355\u4fee\u6539\u4f55\u5fc5\u5927\u52a8\u5e72\u6208\u5462\uff1f<\/p>\n<p style=\"margin: 1em 0px;\">\u8fd9\u91cc\u501f\u9274\u4e86daimajia\u7684\u601d\u8def\uff0c\u6307\u793a\u5668\u662f\u7528\u4ee3\u7801\u7ed8\u51fa\u6765\u7684\uff0c\u600e\u4e48\u7ed8\u5462\uff1f\u770b\u4ee3\u7801\uff0c\u4ee5\u9009\u4e2d\u7684\u72b6\u6001\u4e3a\u4f8b\uff0c\u7ed8\u5236\u4e00\u6b21\u4fbf\u53ef\uff0c\u5c06drawable\u5b58\u8d77\u6765\u4f7f\u7528\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">Drawable selectedDrawable;\n\nGradientDrawable selectedGradientDrawable = new GradientDrawable();\n\n\/\/\u8bbe\u7f6e\u6307\u793a\u5668\u7684\u989c\u8272\n\nselectedGradientDrawable.setColor(selectedIndicatorColor);\n\n\/\/\u8bbe\u7f6e\u6307\u793a\u5668\u7684\u5f62\u72b6\n\nselectedGradientDrawable.setShape(GradientDrawable.RECTANGLE);\n\n\/\/\u8bbe\u7f6e\u6307\u793a\u5668\u7684\u5927\u5c0f\n\nselectedGradientDrawable.setSize(selectedIndicatorWidth, selectedIndicatorHeight);\n\nselectedLayerDrawable = new LayerDrawable(new Drawable[]{selectedGradientDrawable});\n\nselectedDrawable = selectedLayerDrawable;<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u8fd9\u6837\u6307\u793a\u5668\u7684\u5f62\u72b6\uff0c\u5927\u5c0f\uff0c\u989c\u8272\u53ef\u4ee5\u968f\u610f\u6362\u4e86\uff0c\u652f\u6301\u6362\u80a4\u4e5f\u66f4\u5bb9\u6613<\/p>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u6dfb\u52a0\u6307\u793a\u5668\u2013\u4f4d\u7f6e<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u5927\u5bb6\u90fd\u77e5\u9053\u5728xml\u6587\u4ef6\u4e2d\u4f7f\u7528RelativeLayout\u7236\u5e03\u5c40\u53ef\u4ee5\u63a7\u5236\u5b50\u5e03\u5c40\u7684\u4f4d\u7f6e\uff0c\u7528\u4ee3\u7801\u600e\u4e48\u53bb\u505a\u5462\uff1f\u9996\u5148\uff0cBannerLayout\u662f\u7ee7\u627f\u4e0eRelativeLayout\u7684\uff0c\u770b\u4ee3\u7801<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">  RelativeLayout.LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);\n\n  switch (indicatorPosition) {\n\n      case centerBottom:\/\/\u4e0b\u4e2d\n\n          params.addRule(RelativeLayout.CENTER_HORIZONTAL);\n\n          params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);\n\n          break;\n\n      case rightBottom:\/\/\u53f3\u4e0b\n\n          params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);\n\n          params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);\n\n          break;\n\n  }\n\n\/\/\u6dfb\u52a0\u6307\u793a\u5668\u5bb9\u5668\u5e03\u5c40\u5230BannerLayout\n\n addView(indicatorContainer, params);<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4e24\u4e2a\u5c5e\u6027\u5fc5\u987b\u5206\u5f00\u6dfb\u52a0\u4e0d\u80fd\u5199\u6210<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT|RelativeLayout.ALIGN_PARENT_BOTTOM);<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u5982\u4f55\u8bbe\u7f6e\u6307\u793a\u5668margin\u548cpadding\u8fd9\u91cc\u5c31\u4e0d\u518d\u591a\u8bf4<\/p>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u5207\u6362\u6307\u793a\u5668<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u6211\u4e4b\u524d\u7684\u60f3\u6cd5\u662f\u8fd9\u6837\u7684\uff0c\u4e0d\u7528\u5faa\u73af\u505a\uff0c\u53ea\u9700\u77e5\u9053\u4e0a\u4e00\u4e2a\u9009\u4e2d\u7684\u9875\u9762\u548c\u5373\u5c06\u8981\u8df3\u8f6c\u7684\u9875\u9762\u4f4d\u7f6e\u5373\u53ef\uff0c\u5b9e\u73b0\u601d\u8def\u662f\u8fd9\u6837\u7684<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">private void switchIndicator(int currentPosition) {\n\n    if (oldPosition != -1){\n\n        ((ImageView)indicatorContainer.getChildAt(oldPosition)).setImageDrawable(unSelectedDrawable);\n\n    }\n\n    ((ImageView)indicatorContainer.getChildAt(currentPosition)).setImageDrawable(selectedDrawable);\n\n    oldPosition = currentPosition;\n\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4f46\u5b9e\u9645\u7684\u8fd0\u884c\u6548\u679c\u5374\u53ef\u80fd\u51fa\u73b0\u9519\u4e71\u7684\u73b0\u8c61\uff0c\u4e0d\u77e5\u662f\u54ea\u91cc\u51fa\u4e86\u95ee\u9898\uff0c\u76ee\u524d\u5c31\u91c7\u7528\u4e86\u5faa\u73af\u6765\u505a\uff0c\u540e\u671f\u53ef\u80fd\u4f1a\u6539\u8fdb\uff0c\u8fd9\u6837\u505a\u867d\u7136\u7b80\u5355\uff0c\u4f46\u6548\u7387\u59cb\u7ec8\u4e0d\u9ad8<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">private void switchIndicator(int currentPosition) {\n\n    for (int i = 0; i &lt; indicatorContainer.getChildCount(); i++) {\n\n        ((ImageView) indicatorContainer.getChildAt(i)).setImageDrawable(i == currentPosition ? selectedDrawable : unSelectedDrawable);\n\n    }\n\n}<\/code><\/pre>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u6dfb\u52a0\u9875\u9762\u70b9\u51fb\u76d1\u542c\u56de\u8c03<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u7528\u6cd5\u5c31\u50cfListView\u7684setOnItemClickListener\u4e00\u6837\uff0c\u6765\u770b\u770b\u4ee3\u7801\u5982\u4f55\u5b9e\u73b0<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">private OnBannerItemClickListener onBannerItemClickListener;\n\n\/\/\u7ed9\u6bcf\u4e2a\u9875\u9762\u6dfb\u52a0\u70b9\u51fb\u4e8b\u4ef6\n\n imageView.setOnClickListener(new OnClickListener() {\n\n            @Override\n\n            public void onClick(View v) {\n\n                if (onBannerItemClickListener != null) {\n\n                    \/\/\u4e0d\u76f4\u63a5\u5904\u7406\u70b9\u51fb\u4e8b\u4ef6\uff0c\u8f6c\u4ea4\u7ed9onBannerItemClickListener\n\n                    onBannerItemClickListener.onItemClick(position);\n\n                }\n\n            }\n\n        });\n\npublic void setOnBannerItemClickListener(OnBannerItemClickListener onBannerItemClickListener) {\n\n    this.onBannerItemClickListener = onBannerItemClickListener;\n\n}\n\npublic interface OnBannerItemClickListener {\n\n    void onItemClick(int position);\n\n}<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4f7f\u7528<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">bannerLayout.setOnBannerItemClickListener(new BannerLayout.OnBannerItemClickListener() {\n\n            @Override\n\n            public void onItemClick(int position) {\n\n                \/\/\u5904\u7406\u70b9\u51fb\u4e8b\u4ef6\n\n            }\n\n        });<\/code><\/pre>\n<h2 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em; border-bottom: 2px solid #ef7060; display: flex;\"><span style=\"display: inline-block; font-weight: bold; background: #ef7060; color: #ffffff; padding: 3px 10px 1px; border-top-right-radius: 3px; border-top-left-radius: 3px; margin-right: 3px;\">\u9047\u5230\u7684\u4e00\u4e9b\u5751<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u4e0a\u7bc7\u8bb2\u5230\u4e86<a href=\"https:\/\/github.com\/bingoogolapple\/BGABanner-Android\" target=\"_blank\">BGABanner-Android<\/a>,\u90e8\u5206\u601d\u60f3\u4e5f\u662f\u53c2\u8003\u8fd9\u4e2a\u5e93\u7684\uff0c\u4f8b\u5982\u6307\u793a\u5668\u4f4d\u7f6e\u7684\u5904\u7406\u65b9\u6848\uff0c\u4f46\u6211\u8981\u8bf4\u7684\u5751\u4e5f\u5728\u8fd9\u91cc\uff0c\u4f4e\u4e8e3\u5f20\u56fe\u7247\u5c31\u4f1a\u76f4\u63a5\u629b\u5f02\u5e38\uff0c\u6211\u8bd5\u7740\u5c06\u5f02\u5e38\u4e0d\u629b\u51fa\u770b\u770b\uff0c\u4e00\u5f20\u6216\u8005\u4e24\u5f20\u56fe\u7247\u7684\u65f6\u5019\u5207\u6362\u6548\u679c\u60e8\u4e0d\u5fcd\u7779\uff08\u6211\u731c\u60f3\u548cViewPager\u7684\u61d2\u52a0\u8f7d\u673a\u5236\u6709\u5173\uff09\uff0c\u6240\u4ee5\u4f5c\u8005\u5904\u7406\u4e3a\u76f4\u63a5\u629b\u5f02\u5e38\uff0c\u4f46\u8fd9\u6837\u4e0d\u884c\u554a\uff0c\u9700\u6c42\u4e0d\u53ef\u63a7\u5236\u554a\uff0c\u5fc5\u987b\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4e0d\u7136\u5c31\u50cf\u5b9a\u65f6\u70b8\u5f39\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u95ee\u9898\u89e3\u51b3\u601d\u8def\uff1a\u65e2\u7136\u8f6e\u64ad\u662f\u4f2a\u7684\uff0c\u56fe\u7247\u7684\u5f20\u6570\u4e5f\u53ef\u4ee5\u662f\u4f2a\u7684\uff0c\u53ea\u9700\u8981\u7ed9\u7528\u6237\u770b\u8d77\u6765\u662f\u90a3\u6837\u5c31\u884c\u4e86\uff0c1\u5f20\u4e5f\u53ef\u4ee5\u662f3\u00d71\u5f20\u76f8\u540c\u7684\u56fe\u7247\uff0c2\u5f20\u4e5f\u53ef\u4ee5\u662f2\u00d72\u5f20\u76f8\u540c\u56fe\u7247\uff0c3\u5f20\u53ca\u4ee5\u4e0a\u6ca1\u95ee\u9898\u5c31\u65e0\u9700\u5904\u7406\uff0c\u5173\u952e\u4ee3\u7801<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 10px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 10px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; margin: 0.5em; padding: 3px 5px; overflow-x: auto; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\/\/\u6dfb\u52a0\u672c\u5730\u56fe\u7247\u8def\u5f84\n\n    public void setViewRes(List&lt;Integer&gt; viewRes) {\n\n        List&lt;View&gt; views = new ArrayList&lt;&gt;();\n\n        itemCount = viewRes.size();\n\n        \/\/\u4e3b\u8981\u662f\u89e3\u51b3\u5f53item\u4e3a\u5c0f\u4e8e3\u4e2a\u7684\u65f6\u5019\u6ed1\u52a8\u6709\u95ee\u9898\uff0c\u8fd9\u91cc\u5c06\u5176\u62fc\u51d1\u62103\u4e2a\u4ee5\u4e0a\n\n        if (itemCount &lt; 1) {\/\/\u5f53item\u4e2a\u65700\n\n            throw new IllegalStateException(\"item count not equal zero\");\n\n        } else if (itemCount &lt; 2) {\/\/\u5f53item\u4e2a\u6570\u4e3a1\n\n            views.add(getImageView(viewRes.get(0), 0));\n\n            views.add(getImageView(viewRes.get(0), 0));\n\n            views.add(getImageView(viewRes.get(0), 0));\n\n        } else if (itemCount &lt; 3) {\/\/\u5f53item\u4e2a\u6570\u4e3a2\n\n            views.add(getImageView(viewRes.get(0), 0));\n\n            views.add(getImageView(viewRes.get(1), 1));\n\n            views.add(getImageView(viewRes.get(0), 0));\n\n            views.add(getImageView(viewRes.get(1), 1));\n\n        } else {\n\n            for (int i = 0; i &lt; viewRes.size(); i++) {\n\n                views.add(getImageView(viewRes.get(i), i));\n\n            }\n\n        }\n\n        setViews(views);\n\n    }<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u6dfb\u52a0\u7f51\u7edc\u5730\u5740\u548c\u672c\u5730\u7684\u601d\u8def\u5dee\u4e0d\u591a\uff0c\u4f7f\u7528\u7684\u662fGlide\u6765\u5904\u7406\u52a0\u8f7d\u7f51\u7edc\u56fe\u7247\uff0c\u8fd8\u6709\u5c31\u662f\u6dfb\u52a0\u5404\u79cd\u81ea\u5b9a\u4e49\u5c5e\u6027\u3002<\/p>\n<p style=\"margin: 1em 0px;\">github\u5730\u5740<a href=\"https:\/\/github.com\/dongjunkun\/BannerLayoutDemo\" target=\"_blank\">BannerLayoutDemo<\/a>\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u539f\u6587\u51fa\u5904\uff1a <a href=\"http:\/\/www.jianshu.com\/p\/bf3bc1f2df5c\" target=\"_blank\">dongjunkun<\/a><\/p>\n<table style=\"border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; text-align: left; overflow: auto; display: table; overflow-wrap: break-word; word-break: break-all;\" width=\"817\">\n<thead>\n<tr>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">\u80fd\u529b<\/th>\n<th style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top; font-weight: bold; background-color: #fff9f9; color: #ef7060;\">\u5b9e\u73b0\u8981\u70b9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u65e0\u9650\u8f6e\u64ad<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">Adapter getCount \u7528 Integer.MAX_VALUE\uff0c\u6309\u771f\u5b9e\u9875\u53d6\u6a21<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u5207\u6362\u4e0d\u95ea<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u53cd\u5c04\u6539 Scroller\uff0c\u62c9\u957f duration<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u81ea\u52a8\u64ad\u653e<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">Handler \u53d1\u5ef6\u8fdf\u6d88\u606f\uff0c\u89e6\u6478\u65f6\u6682\u505c<\/td>\n<\/tr>\n<tr>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u6307\u793a\u5668 \/ \u70b9\u51fb<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u81ea\u7ed8\u5706\u70b9\u968f page \u5207\u6362\uff1b\u5bf9\u5916\u66b4\u9732 item \u70b9\u51fb<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote style=\"margin: 20px 0px; display: block; font-size: 0.9em; overflow: auto; border-left: 3px solid #ef7060; color: #6a737d; padding: 10px 10px 10px 20px; background: #fff9f9;\">\n<p style=\"margin: 1em 0px;\"><strong>\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1a\u5e7f\u544a\u680f\u4e0d\u5fc5\u4e0a\u91cd\u5e93\uff1aViewPager \u505a\u4f2a\u65e0\u9650\u8f6e\u64ad\uff0c\u653e\u6162\u5207\u6362\u3001Handler \u81ea\u52a8\u7ffb\u9875\uff0c\u518d\u753b\u6307\u793a\u5668\u5e76\u8865\u4e0a OnItemClickListener\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u5e7f\u544a\u680f\u8f6e\u5b50\u5f88\u597d\u627e\uff0c\u4f46\u5b8c\u5168\u5408\u7528\u7684\u5e76\u4e0d\u591a\uff1a\u6709\u7684\u7ed1\u6b7b Picasso \u5403\u5185\u5b58\uff0c\u6709\u7684\u5c11\u4e8e\u4e09\u9875\u5c31\u629b\u5f02\u5e38\u3002\u672c\u7bc7\u4ece View [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[195],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1245"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1245"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1245\/revisions"}],"predecessor-version":[{"id":1289,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1245\/revisions\/1289"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}