{"id":1635,"date":"2022-09-15T14:21:29","date_gmt":"2022-09-15T06:21:29","guid":{"rendered":"https:\/\/cocozq.com\/?p=1635"},"modified":"2022-09-15T14:21:29","modified_gmt":"2022-09-15T06:21:29","slug":"%e5%ae%89%e5%8d%93tablayout%e4%bd%8e%e7%89%88%e6%9c%ac%e7%9a%84%e5%85%bc%e5%ae%b9%e6%80%a7%e5%a4%a7%e5%9d%91","status":"publish","type":"post","link":"https:\/\/cocozq.com\/?p=1635","title":{"rendered":"\u5b89\u5353TabLayout\u4f4e\u7248\u672c\u7684\u517c\u5bb9\u6027\u5927\u5751"},"content":{"rendered":"<p>\u524d\u6bb5\u65f6\u95f4\u6211\u5c1d\u8bd5\u4e86\u628a\u53ef\u53ef\u62fc\u97f3\u8f93\u5165\u6cd5\u79fb\u690d\u52309\u952e\u624b\u673a\u4e0a\uff0c\u6bd4\u5982\u591a\u4eb2\u7684<code>F22<\/code>\u4ee5\u53ca\u65e5\u672c\u4e00\u4e9b\u50cf\u5404\u79cd<code>Softbank<\/code>\u5b9a\u5236\u673a\uff0c\u6700\u4f4e\u7248\u672c\u964d\u81f3\u5b89\u5353<code>5.0<\/code>\u7248\u672c\uff0c\u9664\u4e86\u6309\u952e\u7684\u9002\u914d\u8fd0\u884c\u65b9\u9762\u6ca1\u6709\u592a\u5927\u95ee\u9898\uff0c\u540e\u6765\u6211\u5728\u81ea\u5df1\u7684\u7535\u5b50\u7eb8\u4e66\u4e0a\u8dd1\u4e86\u4e00\u4e0b\uff0c\u4e5f\u8fd8\u4e0d\u9519\uff0c\u5177\u4f53\u89c1<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/cocozq.com\/?p=1623\"><strong>\u53ef\u53ef\u62fc\u97f3\u8f93\u5165\u6cd5\u5728QUADERNO\u4e0a\u4f53\u9a8c<\/strong><\/a>\u3002<\/p>\n<p>\u4e2d\u79cb\u8282\u56de\u5bb6\u7ed9\u5916\u5a46\u7684\u7535\u89c6\u88c5\u4e0a\u4e86\u6211\u6700\u8fd1\u521a\u66f4\u65b0\u7684<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/cocozq.com\/?p=1611\"><strong>\u53ef\u53ef\u684c\u9762<\/strong><\/a>\u7248\u672c\uff0c\u4f46\u662f\u53d1\u73b0\u65e0\u6cd5\u5207\u6362\u9ed8\u8ba4\u684c\u9762\uff0c\u7cfb\u7edf\u505a\u4e86\u4fee\u6539\uff0c\u4e5f\u5c31\u662f\u6211\u505a\u7684\u4e00\u952e\u542f\u52a8\u6ca1\u6cd5\u7528\uff0c\u4f30\u8ba1\u8ddf\u5c0f\u7c73\u7684\u5dee\u4e0d\u591a\uff0c\u672c\u6765\u6211\u662f\u60f3\u7981\u7528\u7cfb\u7edf\u684c\u9762\u7684\uff0c\u4f46\u662f\u60f3\u4e86\u4e00\u4e0b\u8fd8\u662f\u7b97\u4e86\u4e86\uff0c\u6bd5\u7adf\u8fd9\u4e0d\u662f\u6d4b\u8bd5\u8bbe\u5907\uff0c\u6240\u4ee5\u8fd8\u662f\u60f3\u901a\u8fc7\u8f93\u5165\u6cd5\u6765\u5b9e\u73b0\u8fd9\u4e2a\u4e00\u952e\u542f\u52a8\u5e94\u7528\u7684\u529f\u80fd\uff0c\u56e0\u4e3a\u5f88\u591a\u673a\u9876\u76d2\u8fd8\u662f<code>4.4<\/code>\u7248\u672c\u7684\uff0c\u6211\u5c1d\u8bd5\u628a\u53ef\u53ef\u62fc\u97f3\u8f93\u5165\u6cd5\u6700\u4f4e\u7248\u672c\u964d\u4f4e\u5230\u5b89\u5353<code>4.4<\/code>\u8fdb\u884c\u6d4b\u8bd5\uff0c\u4f46\u662f\u8fd0\u884c\u4e4b\u540e\u53d1\u73b0\u7f16\u8f91\u6846\u4e00\u65e6\u6fc0\u6d3b\u8f93\u5165\u6cd5\u524d\u53f0\u5e94\u7528\u6574\u4e2a\u50f5\u6b7b\uff0c\u8ddf\u8e2a\u4e86\u4e00\u4e0b\u53d1\u73b0\u662f\u6211\u5728\u8f6f\u4ef6\u7684\u7b26\u53f7\u9762\u677f\u4e0a\u7528\u5230\u4e86\u63a7\u4ef6<code>com.google.android.material.tabs.TabLayout<\/code>\uff0c\u4f1a\u76f4\u63a5\u62a5\u9519<code>The style on this component requires your app theme to be Theme.AppCompat<\/code>\uff0c\u4f46\u662f\u5728\u8bbe\u7f6e\u754c\u9762\u4f7f\u7528\u8fd9\u4e2a\u63a7\u4ef6\u662f\u6b63\u5e38\u7684\uff0c\u4e8e\u662f\u6211\u8ddf\u8e2a\u4e86\u4e00\u4e0b\uff0c\u53d1\u73b0\u662f<code>ThemeEnforcment.java<\/code>\u5728\u68c0\u67e5\u4e0a\u4e0b\u6587\u4e3b\u9898\u7684\u65f6\u5019\u62a5\u9519\uff0c\u7531\u4e8e<code>Activity<\/code>\u662f\u7ee7\u627f<code>ContentThemeWrapper<\/code>\uff0c\u6ca1\u6709\u95ee\u9898\uff0c\u4f46\u662f\u8f93\u5165\u6cd5\u521b\u5efa\u7684<code>Candidates<\/code>\u89c6\u56fe\u4e0a\u4e0b\u6587\u662f<code>InputMethodService<\/code>\uff0c\u7406\u8bba\u4e0a\u6765\u8bf4\u5b83\u5e94\u8be5\u4f7f\u7528<code>Application<\/code>\u7684\u4e3b\u9898\u914d\u7f6e\uff0c\u4e0d\u5e94\u8be5\u51fa\u73b0\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f46\u662f\u4e8b\u4e0e\u613f\u8fdd\uff0cGoogle\u7684\u4eba\u5728\u5f00\u53d1<code>TabLayout<\/code>\u7ec4\u4ef6\u7684\u65f6\u5019\u5e94\u8be5\u6ca1\u6709\u5bf9\u4f4e\u7248\u672c\u7684\u7cfb\u7edf\u8fdb\u884c\u8fc7\u517c\u5bb9\u6d4b\u8bd5\uff0c\u672c\u6765\u6211\u8fd8\u60f3\u901a\u8fc7\u53cd\u5c04\u4fee\u6539\u4e00\u4e9b\u5c5e\u6027\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f46\u662f\u8ddf\u5230<code>Resources.java<\/code>\u7684<code>obtainStyledAttributes<\/code>\u53d1\u73b0\u95ee\u9898\u6700\u7ec8\u6307\u5411\u4e86<code>AssetManager<\/code>\u7684<code>applyStyle<\/code>\uff0c\u8fd9\u4e2a\u662f\u8c03\u7528<code>native<\/code>\u5c42\u7684\u65b9\u6cd5\uff0c\u6ca1\u4ec0\u4e48\u620f\u4e86\u3002<\/p>\n<pre><code class=\"language-java line-numbers\">\/\/ ThemeEnforcment.java\nprivate static void checkTheme(\n    @NonNull Context context, @NonNull int[] themeAttributes, String themeName) {\n    if (!isTheme(context, themeAttributes)) {\n        throw new IllegalArgumentException(\n            \"The style on this component requires your app theme to be \"\n            + themeName\n            + \" (or a descendant).\");\n    }\n}\n\/\/ Context.java\npublic final TypedArray obtainStyledAttributes(\n    int resid, int[] attrs) throws Resources.NotFoundException {\n    return getTheme().obtainStyledAttributes(resid, attrs);\n}\n\n\/\/ Resouces.java\npublic TypedArray obtainStyledAttributes(int[] attrs) {\n    int len = attrs.length;\n    TypedArray array = getCachedStyledAttributes(len);\n    array.mRsrcs = attrs;\n    AssetManager.applyStyle(mTheme, 0, 0, 0, attrs,\n                            array.mData, array.mIndices);\n    return array;\n}\n<\/code><\/pre>\n<p>\u89e3\u51b3\u529e\u6cd5\u53ea\u80fd\u662f\u6362\u63a7\u4ef6\uff0c\u76ee\u524d\u6211\u4e0d\u60f3\u52a8\u8fd9\u4e00\u5757\u4e86\uff0c\u5148\u653e\u5f03<code>4.4<\/code>\u7248\u672c\u652f\u6301\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u6bb5\u65f6\u95f4\u6211\u5c1d\u8bd5\u4e86\u628a\u53ef\u53ef\u62fc\u97f3\u8f93\u5165\u6cd5\u79fb\u690d\u52309\u952e\u624b\u673a\u4e0a\uff0c\u6bd4\u5982\u591a\u4eb2\u7684F22\u4ee5\u53ca\u65e5\u672c\u4e00\u4e9b\u50cf\u5404\u79cdSoftbank\u5b9a\u5236\u673a\uff0c\u6700 &hellip; <a href=\"https:\/\/cocozq.com\/?p=1635\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;\u5b89\u5353TabLayout\u4f4e\u7248\u672c\u7684\u517c\u5bb9\u6027\u5927\u5751&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[97,48],"class_list":["post-1635","post","type-post","status-publish","format-standard","hentry","category-22","tag-android","tag-48","hfeed"],"_links":{"self":[{"href":"https:\/\/cocozq.com\/index.php?rest_route=\/wp\/v2\/posts\/1635","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cocozq.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cocozq.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cocozq.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cocozq.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1635"}],"version-history":[{"count":1,"href":"https:\/\/cocozq.com\/index.php?rest_route=\/wp\/v2\/posts\/1635\/revisions"}],"predecessor-version":[{"id":1636,"href":"https:\/\/cocozq.com\/index.php?rest_route=\/wp\/v2\/posts\/1635\/revisions\/1636"}],"wp:attachment":[{"href":"https:\/\/cocozq.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cocozq.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cocozq.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}