{"id":7862,"date":"2023-09-01T11:07:23","date_gmt":"2023-09-01T03:07:23","guid":{"rendered":"https:\/\/www.zhidianwl.com\/zhidian\/2023\/7862\/"},"modified":"2023-09-01T11:07:23","modified_gmt":"2023-09-01T03:07:23","slug":"eclipse%e5%bc%80%e5%8f%91%e5%ae%89%e5%8d%93app%e5%b8%83%e5%b1%80%e6%a0%b7%e5%bc%8f%e6%9c%89%e9%82%a3%e4%ba%9b%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.com\/zhidian\/2023\/7862\/","title":{"rendered":"eclipse\u5f00\u53d1\u5b89\u5353app\u5e03\u5c40\u6837\u5f0f\u6709\u90a3\u4e9b\uff1f"},"content":{"rendered":"

\u5728Eclipse\u4e2d\u5f00\u53d1Android\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u5f00\u53d1\u8005\u9009\u62e9\u4f7f\u7528\u5e03\u5c40\u6837\u5f0f\uff08Layout Styles\uff09\u6765\u8bbe\u8ba1UI\u3002\u5e03\u5c40\u6837\u5f0f\uff08Layout Styles\uff09\u662fAndroid\u5e94\u7528\u8bbe\u8ba1\u4e2d\u7684\u4e00\u9879\u91cd\u8981\u4efb\u52a1\uff0c\u80fd\u5e2e\u52a9\u5f00\u53d1\u8005\u5728\u8bbe\u8ba1UI\u65f6\u51cf\u5c11\u91cd\u590d\u4ee3\u7801\uff0c\u63d0\u9ad8\u6548\u7387\uff0c\u4ece\u800c\u66f4\u5feb\u5730\u5b9e\u73b0\u51fa\u8272\u7684\u5e94\u7528\u754c\u9762\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5728Eclipse\u4e2d\u5f00\u53d1Android\u5e94\u7528\u65f6\uff0c\u5982\u4f55\u8bbe\u7f6e\u548c\u4f7f\u7528\u5e03\u5c40\u6837\u5f0f\u3002<\/p>\n

1.\u539f\u7406\u7b80\u4ecb<\/p>\n

\u5e03\u5c40\u6837\u5f0f\uff08Layout Styles\uff09\u5c31\u662f\u5c06\u4e00\u4e9b\u901a\u7528\u7684\u5916\u89c2\u8bbe\u7f6e\uff08\u5982\uff1a\u989c\u8272\u3001\u5927\u5c0f\u3001\u5b57\u4f53\u7b49\uff09\u62bd\u79bb\u51fa\u6765\u5b9a\u4e49\u4e3a\u4e00\u4e2a\u6837\u5f0f\uff08Style\uff09\u6587\u4ef6\uff0c\u7136\u540e\u5728\u5e03\u5c40\u6587\u4ef6\uff08Layout XML\uff09\u4e2d\u5f15\u7528\u8fd9\u4e9b\u6837\u5f0f\u3002\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\uff0c\u5f53\u9700\u8981\u4fee\u6539\u67d0\u4e2a\u5916\u89c2\u8bbe\u7f6e\u65f6\uff0c\u53ea\u9700\u8981\u4fee\u6539\u6837\u5f0f\u6587\u4ef6\uff0c\u800c\u4e0d\u9700\u8981\u9010\u4e2a\u4fee\u6539\u6bcf\u4e2a\u5e03\u5c40\u6587\u4ef6\u3002\u6b64\u5916\uff0c\u5e03\u5c40\u6837\u5f0f\u8fd8\u80fd\u5e2e\u52a9\u6211\u4eec\u5b9e\u73b0\u5728\u4e0d\u540c\u8bbe\u5907\u548c\u5c4f\u5e55\u4e0a\u9002\u5e94\u4e0d\u540c\u5c3a\u5bf8\u548c\u5206\u8fa8\u7387\u7b49\u65b9\u9762\u7684\u9700\u6c42\u3002<\/p>\n

2.\u521b\u5efa\u6837\u5f0f<\/p>\n

\u5728Eclipse\u4e2d\uff0c\u5e03\u5c40\u6837\u5f0f\u901a\u5e38\u5b9a\u4e49\u5728\u201cres\/values\/\u201d\u76ee\u5f55\u4e0b\u7684\u201cstyles.xml\u201d\u6587\u4ef6\u4e2d\u3002\u5982\u679c\u9879\u76ee\u4e2d\u6ca1\u6709\u8fd9\u4e2a\u6587\u4ef6\uff0c\u9700\u8981\u53f3\u952e->New->\u6587\u4ef6\uff0c\u8f93\u5165\u6587\u4ef6\u540d\u201cstyles.xml\u201d\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6837\u5f0f\u6587\u4ef6\u3002\u63a5\u4e0b\u6765\uff0c\u5728styles.xml\u4e2d\u4f7f\u7528\u6807\u7b7e\u6765\u521b\u5efa\u6837\u5f0f\u3002\u4f8b\u5982\uff1a<\/p>\n

“`xml<\/p>\n<\/p>\n

#FF0000<\/p>\n

20sp<\/p>\n<\/p>\n

“`<\/p>\n

\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a\u201cMyCustomTextStyle\u201d\u7684\u6837\u5f0f\uff0c\u5305\u542b\u4e24\u4e2a\u5c5e\u6027\uff1a\u6587\u5b57\u989c\u8272\uff08textColor\uff09\u4e3a\u7ea2\u8272\uff08#FF0000\uff09\uff0c\u6587\u5b57\u5927\u5c0f\uff08textSize\uff09\u4e3a20sp\u3002<\/p>\n

3.\u5e94\u7528\u6837\u5f0f<\/p>\n

\u5728\u5e03\u5c40\u6587\u4ef6\uff08\u4f8b\u5982\uff1aactivity_main.xml\uff09\u4e2d\uff0c\u53ef\u5f15\u7528\u521a\u521a\u521b\u5efa\u7684\u201cMyCustomTextStyle<\/p>\n

<\/figure>\n<\/p>\n

\u201d\u7684\u6837\u5f0f\u3002\u8981\u5e94\u7528\u6837\u5f0f\uff0c\u53ea\u9700\u8981\u5728\u5bf9\u5e94\u7684View\uff08\u4f8b\u5982\uff1aTextView\u3001Button\u7b49\uff09\u4e0a\u6dfb\u52a0\u201cstyle\u201d\u5c5e\u6027\uff0c\u5e76\u5f15\u7528\u6837\u5f0f\u540d\u3002\u4f8b\u5982\uff1a<\/p>\n

“`xml<\/p>\n<\/p>\n

android:id=”@+id\/textview1″<\/p>\n

android:layout_width=”wrap_content”<\/p>\n

android:layout_height=”wrap_con\u5b89\u5353APP\u5f00\u53d1<\/a>tent”<\/p>\n

style=”@style\/MyCustomTextStyle”<\/p>\n

android:text=”Hello, World!” \/><\/p>\n

“`<\/p>\n

\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u5c06\u201cMyCustomTextStyle\u201d\u6837\u5f0f\u5e94\u7528\u5230\u4e86\u4e00\u4e2aTextView\u4e0a\u3002\u8fd0\u884c\u5e94\u7528\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230TextView\u7684\u6587\u5b57\u989c\u8272\u548c\u5927\u5c0f\u5747\u5df2\u6309\u6837\u5f0f\u8bbe\u7f6e\u751f\u6548\u3002<\/p>\n

4.\u6837\u5f0f\u7ee7\u627f<\/p>\n

\u5728\u521b\u5efa\u6837\u5f0f\u65f6\uff0c\u8fd8\u53ef\u4ee5\u5229\u7528\u7ee7\u627f\u673a\u5236\u6765\u7b80\u5316\u6837\u5f0f\u5b9a\u4e49\u3002\u4f8b\u5982\uff0c\u4f60\u6709\u4e24\u4e2aTextView\uff0c\u5b83\u4eec\u7684\u6587\u5b57\u5927\u5c0f\u76f8\u540c\uff0c\u4f46\u989c\u8272\u4e0d\u540c\u3002\u6b64\u65f6\uff0c\u53ef\u5728\u201cstyles.xml\u201d\u4e2d\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u6837\u5f0f\uff0c\u7136\u540e\u521b\u5efa\u4e24\u4e2a\u5b50\u6837\u5f0f\u5206\u522b\u5b9a\u4e49\u4e0d\u540c\u7684\u989c\u8272\uff0c\u540c\u65f6\u7ee7\u627f\u57fa\u672c\u6837\u5f0f\u4e2d\u7684\u6587\u5b57\u5927\u5c0f\u3002\u4ee3\u7801\u793a\u4f8b\uff1a<\/p>\n

“`xml<\/p>\n

\n

20sp<\/p>\n<\/p>\n

#FF0000<\/p>\n

\u5b89\u5353app\u5236\u4f5c<\/a><\/p>\n<\/p>\n

#0000FF<\/p>\n<\/p>\n

“`<\/p>\n

\u8fd9\u6837\uff0c\u5728\u5e03\u5c40\u6587\u4ef6\u4e2d\u5c31\u53ef\u4ee5\u5206\u522b\u5f15\u7528\u201cRedTextStyle\u201d\u548c\u201cBlueTextStyle\u201d\uff0c\u540c\u65f6\u7ee7\u627f\u201cBaseTextStyle\u201d\u4e2d\u7684\u6587\u5b57\u5927\u5c0f\u5c5e\u6027\u3002<\/p>\n

\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\uff0c\u5728Eclipse\u4e2d\u5f00\u53d1Android\u5e94\u7528\u65f6\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8bbe\u7f6e\u548c\u4f7f\u7528\u5e03\u5c40\u6837\u5f0f\u6765\u4f18\u5316UI\u8bbe\u8ba1\uff0c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5728Eclipse\u4e2d\u5f00\u53d1Android\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u8d8a\u6765\u8d8a\u591a\u7684\u5f00\u53d1\u8005\u9009\u62e9\u4f7f\u7528\u5e03\u5c40\u6837\u5f0f\uff08Layout Styles\uff09\u6765\u8bbe\u8ba1UI\u3002\u5e03\u5c40\u6837\u5f0f\uff08Layout Styles\uff09\u662fAndroid\u5e94\u7528\u8bbe\u8ba1\u4e2d\u7684\u4e00\u9879\u91cd\u8981\u4efb<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[14024,14023,1629,171,2822],"class_list":["post-7862","post","type-post","status-publish","format-standard","hentry","category-zuoapp","tag-appbuilder","tag-app","tag-1629","tag-171","tag-2822"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/7862","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/comments?post=7862"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/7862\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/media?parent=7862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/categories?post=7862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/tags?post=7862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}