{"id":499,"date":"2015-04-20T20:31:18","date_gmt":"2015-04-20T12:31:18","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=499"},"modified":"2026-08-18T12:58:40","modified_gmt":"2026-08-18T04:58:40","slug":"%e6%ac%a2%e8%bf%8e%e5%bc%80%e5%a7%8bandroid%e5%ba%94%e7%94%a8%e5%bc%80%e5%8f%91%e4%b9%8b%e6%97%85%ef%bc%81","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=499","title":{"rendered":"\u6b22\u8fce\u5f00\u59cbAndroid\u5e94\u7528\u5f00\u53d1\u4e4b\u65c5\uff01"},"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;\">\u672c\u7ae0\u8282\u6559\u4f60\u5982\u4f55\u5efa\u7acb\u7b2c\u4e00\u4e2a Android \u5e94\u7528\u7a0b\u5e8f\uff1a\u521b\u5efa\u9879\u76ee\u3001\u8fd0\u884c\u53ef\u8c03\u8bd5\u7248\u672c\uff0c\u4ee5\u53ca\u4e00\u4e9b\u5e94\u7528\u7a0b\u5e8f\u8bbe\u8ba1\u57fa\u7840\u2014\u2014\u521b\u5efa\u7b80\u5355\u7528\u6237\u754c\u9762\uff0c\u5e76\u5904\u7406\u7528\u6237\u8f93\u5165\u3002<\/p>\n<\/blockquote>\n<p style=\"margin: 1em 0px;\"><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image.png\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-3498\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image.png\" alt=\"\" width=\"2151\" height=\"1105\" srcset=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image.png 2151w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image-768x395.png 768w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image-1536x789.png 1536w, https:\/\/ai.zhousir.top\/wp-content\/uploads\/2024\/05\/image-2048x1052.png 2048w\" sizes=\"(max-width: 2151px) 100vw, 2151px\" \/><\/a><\/p>\n<p><!--more--><\/p>\n<p style=\"margin: 1em 0px;\">\u5f00\u59cb\u5b66\u4e60\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section><a href=\"https:\/\/ai.zhousir.top\/?p=446\">\u4e86\u89e3 Android \u5e73\u53f0<\/a><\/section>\n<\/li>\n<li>\n<section><a href=\"https:\/\/ai.zhousir.top\/?p=9\">\u5b89\u88c5\u4e86\u5f00\u53d1\u73af\u5883<\/a><\/section>\n<\/li>\n<li>\n<section><a href=\"https:\/\/ai.zhousir.top\/?p=436\">\u638c\u63e1 Android \u9879\u76ee\u7ed3\u6784<\/a><\/section>\n<\/li>\n<li>\n<section><a href=\"https:\/\/ai.zhousir.top\/?p=442\">Android \u56fe\u5f62\u7528\u6237\u754c\u9762\u76f8\u5173\u77e5\u8bc6<\/a><\/section>\n<\/li>\n<\/ul>\n<hr>\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;\">\u4e00\u3001\u521b\u5efa\u4e00\u4e2a LinearLayout<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u521b\u5efa Android \u65b0\u9879\u76ee\uff0c\u4ece res\/layout \u6253\u5f00 activity_my.xml\uff0c\u4fee\u6539\u5e03\u5c40\u3002\u4fee\u6539\u540e\u7684 res\/layout\/activity_my.xml\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;\">&lt;LinearLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;\n    xmlns:tools=&quot;http:\/\/schemas.android.com\/tools&quot;\n    android:layout_width=&quot;match_parent&quot;\n    android:layout_height=&quot;match_parent&quot;\n    android:orientation=&quot;horizontal&quot; &gt;\n&lt;\/LinearLayout&gt;<\/code><\/pre>\n<p style=\"margin: 1em 0px;\"><a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/LinearLayout.html\" target=\"_blank\" rel=\"noopener\">LinearLayout<\/a> \u662f <a href=\"http:\/\/developer.android.com\/reference\/android\/view\/ViewGroup.html\" target=\"_blank\" rel=\"noopener\">ViewGroup<\/a> \u7684\u5b50\u7c7b\uff0c\u7528\u4e8e\u6c34\u5e73\u6216\u5782\u76f4\u653e\u7f6e\u5b50\u89c6\u56fe\uff0c\u7531 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">android:orientation<\/code> \u8bbe\u5b9a\u65b9\u5411\u3002\u5b50\u5e03\u5c40\u6309 XML \u91cc\u5b9a\u4e49\u7684\u987a\u5e8f\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u53e6\u5916\u4e24\u4e2a\u5c5e\u6027 <a href=\"http:\/\/developer.android.com\/reference\/android\/view\/View.html#attr_android:layout_width\" target=\"_blank\" rel=\"noopener\">android:layout_width<\/a> \u548c <a href=\"http:\/\/developer.android.com\/reference\/android\/view\/View.html#attr_android:layout_height\" target=\"_blank\" rel=\"noopener\">android:layout_height<\/a>\uff0c\u6240\u6709 View \u90fd\u8981\u8bbe\u7f6e\u4ee5\u6307\u5b9a\u5c3a\u5bf8\u3002\u8fd9\u91cc LinearLayout \u662f\u6839\u5e03\u5c40\uff0c\u5bbd\u9ad8\u5e94\u5145\u6ee1\u6574\u4e2a\u5c4f\u5e55\uff0c\u6307\u5b9a\u4e3a <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">match_parent<\/code>\uff0c\u8868\u793a\u5b50 View \u6269\u5f20\u81ea\u5df1\u7684\u5bbd\u9ad8\u6765\u5339\u914d\u7236\u63a7\u4ef6\u3002\u66f4\u591a\u5e03\u5c40\u5c5e\u6027\u89c1 <a href=\"http:\/\/developer.android.com\/guide\/topics\/ui\/declaring-layout.html\" target=\"_blank\" rel=\"noopener\">XML \u5e03\u5c40\u5411\u5bfc<\/a>\u3002<\/p>\n<hr>\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;\">\u4e8c\u3001\u6dfb\u52a0\u4e00\u4e2a\u6587\u672c\u8f93\u5165\u6846<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u4e0e\u5176\u5b83 View \u4e00\u6837\uff0c\u9700\u8981\u5728 XML \u91cc\u6307\u5b9a EditText \u7684\u5c5e\u6027\u3002\u5728\u7ebf\u6027\u5e03\u5c40\u91cc\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u5728 activity_my.xml \u7684\u6807\u7b7e\u5185\u5b9a\u4e49 EditText\uff0cid \u4e3a @+id\/edit_message\u3002<\/section>\n<\/li>\n<li>\n<section>layout_width \u548c layout_height \u8bbe\u4e3a wrap_content\u3002<\/section>\n<\/li>\n<li>\n<section>hint \u5c5e\u6027\u5f15\u7528\u5b57\u7b26\u4e32 edit_message\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">res\/layout\/activity_my.xml\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;\">&lt;EditText android:id=&quot;@+id\/edit_message&quot;\n    android:layout_width=&quot;wrap_content&quot;\n    android:layout_height=&quot;wrap_content&quot;\n    android:hint=&quot;@string\/edit_message&quot; \/&gt;<\/code><\/pre>\n<h3 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;\">android:id<\/h3>\n<p style=\"margin: 1em 0px;\">\u8fd9\u91cc\u5b9a\u4e49 View \u7684\u552f\u4e00\u6807\u8bc6\uff0c\u53ef\u5728\u4ee3\u7801\u91cc\u5f15\u7528\u5e76\u8bfb\u5199\uff08\u4e0b\u4e00\u8bfe\u4f1a\u7528\u5230\uff09\u3002\u4ece XML \u4f7f\u7528\u8d44\u6e90\u5fc5\u987b\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">@<\/code>\uff0c\u540e\u9762\u662f\u8d44\u6e90\u7c7b\u578b\uff08\u8fd9\u91cc\u662f <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">id<\/code>\uff09\uff0c\u7136\u540e\u662f\u540d\u5b57\uff08<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">edit_message<\/code>\uff09\u3002\u5176\u4ed6\u7c7b\u578b\u7684\u8d44\u6e90\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u540d\u5b57\uff0c\u53ea\u8981\u7c7b\u578b\u4e0d\u540c\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">+<\/code> \u53ea\u5728\u7b2c\u4e00\u6b21\u5b9a\u4e49\u8d44\u6e90 ID \u65f6\u9700\u8981\uff0c\u544a\u8bc9 SDK \u521b\u5efa\u8be5 ID\u3002\u7f16\u8bd1\u540e SDK \u53ef\u76f4\u63a5\u4f7f\u7528\uff0c\u4f1a\u5728 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">gen\/R.java<\/code> \u91cc\u521b\u5efa\u4e0e EditText \u5173\u8054\u7684\u6807\u8bc6\u3002ID \u521b\u5efa\u4e4b\u540e\uff0c\u5176\u4ed6\u5730\u65b9\u5f15\u7528\u4e0d\u518d\u9700\u8981 +\u3002\u8fd9\u662f\u552f\u4e00\u9700\u8981 + \u7684\u5c5e\u6027\u3002\u6587\u6863\uff1a<a href=\"http:\/\/developer.android.com\/reference\/android\/view\/View.html#attr_android:id\" target=\"_blank\" rel=\"noopener\">android:id<\/a>\u3002<\/p>\n<h3 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;\">android:layout_width \u548c android:layout_height<\/h3>\n<p style=\"margin: 1em 0px;\">\u4e0d\u5efa\u8bae\u5199\u6b7b\u5177\u4f53\u5927\u5c0f\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">wrap_content<\/code> \u8ba9\u89c6\u56fe\u53ea\u5360\u5185\u5bb9\u5927\u5c0f\uff1b\u82e5\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">match_parent<\/code>\uff0cEditText \u4f1a\u5e03\u6ee1\u6574\u4e2a\u5c4f\u5e55\u53bb\u9002\u5e94\u7236\u5e03\u5c40\u3002\u66f4\u591a\u89c1 <a href=\"http:\/\/developer.android.com\/guide\/topics\/ui\/declaring-layout.html\" target=\"_blank\" rel=\"noopener\">\u5e03\u5c40\u5411\u5bfc<\/a>\u3002<\/p>\n<h3 style=\"margin: 1.2em 0px 1em; padding: 0px; font-weight: bold; font-size: 1.3em;\">android:hint<\/h3>\n<p style=\"margin: 1em 0px;\">\u6587\u672c\u6846\u4e3a\u7a7a\u65f6\u663e\u793a\u8be5\u5b57\u7b26\u4e32\u3002<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">@string\/edit_message<\/code> \u5e94\u5b9a\u4e49\u5728\u5355\u72ec\u7684\u8d44\u6e90\u6587\u4ef6\uff0c\u4e0d\u8981\u628a\u5b57\u7b26\u4e32\u5199\u6b7b\u5728\u5e03\u5c40\u91cc\u3002\u56e0\u4e3a\u5f15\u7528\u7684\u662f\u5df2\u6709\u7c7b\u578b\u7684\u8d44\u6e90\uff0c\u4e0d\u9700\u8981 +\uff1b\u4f46\u82e5\u5c1a\u672a\u5b9a\u4e49\u8be5\u5b57\u7b26\u4e32\uff0c\u6dfb\u52a0\u5f15\u7528\u4f1a\u51fa\u73b0\u7f16\u8bd1\u9519\u8bef\u3002\u5b57\u7b26\u4e32\u8d44\u6e90\u4e0e id \u4f7f\u7528\u4e86\u76f8\u540c\u540d\u79f0 edit_message\uff0c\u4f46\u5f15\u7528\u533a\u5206\u7c7b\u578b\uff0c\u4e0d\u4f1a\u51b2\u7a81\u3002<\/p>\n<hr>\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;\">\u4e09\u3001\u589e\u52a0\u5b57\u7b26\u4e32\u8d44\u6e90<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u9ed8\u8ba4\u9879\u76ee\u5305\u542b <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">res\/values\/strings.xml<\/code>\u3002\u6253\u5f00\u5b83\uff0c\u4e3a edit_message \u589e\u52a0\u5b57\u7b26\u4e32\uff0c\u503c\u4e3a Enter a message.<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u5728 Android Studio \u4ece res\/values \u6253\u5f00 strings.xml\u3002<\/section>\n<\/li>\n<li>\n<section>\u6dfb\u52a0 string \u540d\u4e3a &#8220;edit_message&#8221;\uff0c\u503c\u4e3a &#8220;Enter a message&#8221;\u3002<\/section>\n<\/li>\n<li>\n<section>\u518d\u6dfb\u52a0 &#8220;button_send&#8221;\uff0c\u503c\u4e3a &#8220;Send&#8221;\uff08\u63a5\u4e0b\u6765\u4f1a\u7528\u5230\uff09\u3002<\/section>\n<\/li>\n<li>\n<section>\u5220\u9664 &#8220;hello world&#8221; \u5b57\u7b26\u4e32\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u5b9a\u4e49\u597d\u7684 res\/values\/strings.xml\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;\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\n&lt;resources&gt;\n    &lt;string name=&quot;app_name&quot;&gt;My First App&lt;\/string&gt;\n    &lt;string name=&quot;edit_message&quot;&gt;Enter a message&lt;\/string&gt;\n    &lt;string name=&quot;button_send&quot;&gt;Send&lt;\/string&gt;\n    &lt;string name=&quot;action_settings&quot;&gt;Settings&lt;\/string&gt;\n    &lt;string name=&quot;title_activity_main&quot;&gt;MainActivity&lt;\/string&gt;\n&lt;\/resources&gt;<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u754c\u9762\u4e0a\u7684\u6587\u672c\u90fd\u5e94\u8be5\u5217\u5165\u8d44\u6e90\u6587\u4ef6\uff0c\u65b9\u4fbf\u5355\u72ec\u4fee\u6539\uff0c\u4e5f\u65b9\u4fbf\u6309\u8bed\u8a00\u505a\u672c\u5730\u5316\u3002\u53c2\u89c1 <a href=\"http:\/\/hukai.me\/android-training-course-in-chinese\/basics\/supporting-devices\/index.html\">\u517c\u5bb9\u4e0d\u540c\u7684\u8bbe\u5907\uff08Supporting Different Devices\uff09<\/a>\u3002<\/p>\n<hr>\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;\">\u56db\u3001\u6dfb\u52a0\u4e00\u4e2a\u6309\u94ae<\/span><\/h2>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u7f16\u8f91 res\/layout \u4e0b\u7684 activity_my.xml\u3002<\/section>\n<\/li>\n<li>\n<section>\u5728 LinearLayout \u5185\u90e8\u3001\u7d27\u6328 EditText \u5b9a\u4e49 Button\u3002<\/section>\n<\/li>\n<li>\n<section>width \u548c height \u4e3a &#8220;wrap_content&#8221;\uff0c\u8ba9\u6309\u94ae\u5b8c\u6574\u663e\u793a\u5176\u4e0a\u7684\u6587\u672c\u3002<\/section>\n<\/li>\n<li>\n<section>android:text \u5f15\u7528\u524d\u9762\u5b9a\u4e49\u7684 button_send\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u6b64\u65f6\u7684 LinearLayout\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;\">&lt;LinearLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;\n    xmlns:tools=&quot;http:\/\/schemas.android.com\/tools&quot;\n    android:layout_width=&quot;match_parent&quot;\n    android:layout_height=&quot;match_parent&quot;\n    android:orientation=&quot;horizontal&quot; &gt;\n      &lt;EditText android:id=&quot;@+id\/edit_message&quot;\n        android:layout_width=&quot;wrap_content&quot;\n        android:layout_height=&quot;wrap_content&quot;\n        android:hint=&quot;@string\/edit_message&quot; \/&gt;\n      &lt;Button\n        android:layout_width=&quot;wrap_content&quot;\n        android:layout_height=&quot;wrap_content&quot;\n        android:text=&quot;@string\/button_send&quot; \/&gt;\n&lt;\/LinearLayout&gt;<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">Note\uff1a\u5bbd\u548c\u9ad8\u8bbe\u4e3a <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">wrap_content<\/code>\uff0c\u6309\u94ae\u53ea\u5360\u6587\u672c\u5927\u5c0f\u3002\u8fd9\u4e2a\u6309\u94ae\u4e0d\u9700\u8981 <a href=\"http:\/\/developer.android.com\/reference\/android\/view\/View.html#attr_android:id\" target=\"_blank\" rel=\"noopener\">android:id<\/a>\uff0c\u56e0\u4e3a Activity \u4ee3\u7801\u91cc\u4e0d\u4f1a\u5f15\u7528\u5b83\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u5f53\u524d EditText \u548c Button \u53ea\u9002\u5e94\u5404\u81ea\u5185\u5bb9\u7684\u5927\u5c0f\u3002\u8fd9\u5bf9\u6309\u94ae\u5408\u9002\uff0c\u5bf9\u6587\u672c\u6846\u4e0d\u597d\u2014\u2014\u7528\u6237\u53ef\u80fd\u8f93\u5165\u66f4\u957f\u5185\u5bb9\uff0c\u6700\u597d\u5360\u6ee1\u5c4f\u5e55\u5bbd\u5ea6\u3002LinearLayout \u7528\u6743\u91cd\u8fbe\u5230\u8fd9\u4e2a\u76ee\u7684\uff0c\u5373 <a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/LinearLayout.LayoutParams.html#weight\" target=\"_blank\" rel=\"noopener\">android:layout_weight<\/a>\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u6743\u91cd\u6309\u540c\u7ea7\u90e8\u4ef6\u5206\u914d\u5269\u4f59\u7a7a\u95f4\uff0c\u7c7b\u4f3c\u300c\u4e24\u4efd\u4f0f\u7279\u52a0\u3001\u4e00\u4efd\u5496\u5561\u5229\u53e3\u9152\u300d\u3002\u4e00\u4e2a View \u6743\u91cd 2\u3001\u53e6\u4e00\u4e2a 1\uff0c\u603b\u6570 3\uff0c\u5206\u522b\u5360 2\/3 \u548c 1\/3\uff1b\u518d\u52a0\u7b2c\u4e09\u4e2a\u6743\u91cd 1\uff0c\u5219\u7b2c\u4e00\u4e2a\u5360 1\/2\uff0c\u53e6\u5916\u4e24\u4e2a\u5404\u5360 1\/4\u3002\u4f7f\u7528\u6743\u91cd\u7684\u524d\u63d0\u4e00\u822c\u662f\u628a\u5bbd\u6216\u9ad8\u8bbe\u4e3a 0dp\uff0c\u7531\u7cfb\u7edf\u6309\u6743\u91cd\u8ba1\u7b97\u3002\u5f88\u591a\u60c5\u51b5\u4e0b\u5982\u679c\u8bbe\u4e86 match_parent\uff0c\u6743\u91cd\u8ba1\u7b97\u4f1a\u53d8\u6210\u53cd\u6bd4\uff1a\u6743\u91cd\u5927\u7684\u53cd\u800c\u5360\u7a7a\u95f4\u5c0f\u3002\u6240\u6709 View \u9ed8\u8ba4\u6743\u91cd\u4e3a 0\uff1b\u53ea\u7ed9\u4e00\u4e2a View \u6743\u91cd\u5927\u4e8e 0\uff0c\u5b83\u5c31\u4f1a\u5360\u6389\u5176\u4f59 View \u81ea\u8eab\u4e4b\u5916\u7684\u5168\u90e8\u5269\u4f59\u7a7a\u95f4\u3002\u56e0\u6b64\u8fd9\u91cc\u7ed9 EditText \u6743\u91cd 1\uff0c\u8ba9\u5b83\u5360\u636e\u9664\u6309\u94ae\u4e4b\u5916\u7684\u6240\u6709\u7a7a\u95f4\u3002<\/p>\n<hr>\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;\">\u4e94\u3001\u8ba9\u8f93\u5165\u6846\u5145\u6ee1\u5269\u4f59\u5bbd\u5ea6<\/span><\/h2>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u5728 activity_my.xml \u91cc\u8bbe\u7f6e EditText \u7684 layout_weight \u4e3a 1\u3002<\/section>\n<\/li>\n<li>\n<section>\u540c\u65f6\u628a layout_width \u8bbe\u4e3a 0dp\u3002<\/section>\n<\/li>\n<\/ul>\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;\">&lt;EditText\n    android:layout_weight=&quot;1&quot;\n    android:layout_width=&quot;0dp&quot;\n    ... \/&gt;<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4e3a\u63d0\u5347\u5e03\u5c40\u6548\u7387\uff0c\u8bbe\u6743\u91cd\u65f6\u5e94\u628a EditText \u5bbd\u5ea6\u8bbe\u4e3a 0dp\u3002\u82e5\u4ecd\u7528 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; font-size: 0.9em; overflow-wrap: break-word; padding: 2px 4px; border-radius: 4px; margin: 0px 2px; color: #ef7060; background-color: rgba(27, 31, 35, 0.05); word-break: break-all;\">wrap_content<\/code>\uff0c\u7cfb\u7edf\u8fd8\u8981\u5148\u7b97\u5185\u5bb9\u5bbd\u5ea6\uff0c\u800c\u6743\u91cd\u6700\u7ec8\u4f1a\u5360\u6ee1\u5269\u4f59\u7a7a\u95f4\uff0cwidth \u5c31\u6210\u4e86\u4e0d\u8d77\u4f5c\u7528\u7684\u5c5e\u6027\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u5b8c\u6574\u5e03\u5c40\u6587\u4ef6\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;\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;\n&lt;LinearLayout xmlns:android=&quot;http:\/\/schemas.android.com\/apk\/res\/android&quot;\n    xmlns:tools=&quot;http:\/\/schemas.android.com\/tools&quot;\n    android:layout_width=&quot;match_parent&quot;\n    android:layout_height=&quot;match_parent&quot;\n    android:orientation=&quot;horizontal&quot;&gt;\n    &lt;EditText android:id=&quot;@+id\/edit_message&quot;\n        android:layout_weight=&quot;1&quot;\n        android:layout_width=&quot;0dp&quot;\n        android:layout_height=&quot;wrap_content&quot;\n        android:hint=&quot;@string\/edit_message&quot; \/&gt;\n    &lt;Button\n        android:layout_width=&quot;wrap_content&quot;\n        android:layout_height=&quot;wrap_content&quot;\n        android:text=&quot;@string\/button_send&quot; \/&gt;\n&lt;\/LinearLayout&gt;<\/code><\/pre>\n<hr>\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;\">\u516d\u3001\u8fd0\u884c\u5e94\u7528<\/span><\/h2>\n<p style=\"margin: 1em 0px;\">\u6574\u4e2a\u5e03\u5c40\u9ed8\u8ba4\u5e94\u7528\u4e8e\u521b\u5efa\u9879\u76ee\u65f6 SDK \u5de5\u5177\u81ea\u52a8\u751f\u6210\u7684 Activity\uff0c\u8fd0\u884c\u770b\u6548\u679c\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u5728 Android Studio \u91cc\u70b9\u51fb\u5de5\u5177\u680f Run \u6309\u94ae <img decoding=\"async\" src=\"http:\/\/hukai.me\/android-training-course-in-chinese\/basics\/firstapp\/eclipse-run.png\" alt=\"\" \/><\/section>\n<\/li>\n<li>\n<section>\u6216\u8005\u4f7f\u7528\u547d\u4ee4\u884c\uff0c\u8fdb\u5165\u9879\u76ee\u6839\u76ee\u5f55\u76f4\u63a5\u6267\u884c\u3002<\/section>\n<\/li>\n<\/ul>\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;\">\u6b65\u9aa4<\/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;\">\u5173\u952e\u5c5e\u6027<\/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;\">\u76ee\u7684<\/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;\">\u6839 LinearLayout<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">orientation=horizontal\uff0c\u5bbd\u9ad8 match_parent<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u6a2a\u5411\u6392\u5b50\u89c6\u56fe\u5e76\u94fa\u6ee1\u5c4f\u5e55<\/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;\">EditText<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">id\u3001wrap_content\u3001hint<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u8f93\u5165\u6846\uff0c\u7a7a\u65f6\u663e\u793a\u63d0\u793a<\/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;\">\u5b57\u7b26\u4e32\u8d44\u6e90<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">edit_message \/ button_send<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u6587\u6848\u8fdb strings.xml\uff0c\u65b9\u4fbf\u6539\u548c\u672c\u5730\u5316<\/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;\">Button<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">wrap_content + text<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u53d1\u9001\u6309\u94ae\uff0c\u4ee3\u7801\u91cc\u53ef\u4e0d\u5f15\u7528 id<\/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;\">\u6743\u91cd<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">layout_weight=1\uff0clayout_width=0dp<\/td>\n<td style=\"font-size: 0.75em; padding: 9px 12px; line-height: 22px; border: 1px solid #ef7060; vertical-align: top;\">\u8f93\u5165\u6846\u5403\u6389\u6309\u94ae\u4ee5\u5916\u7684\u5269\u4f59\u5bbd\u5ea6<\/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\u5148\u7528 match_parent \u7684\u6c34\u5e73 LinearLayout \u653e\u4e0b EditText \u548c Button\uff0c\u6587\u6848\u8fdb\u5b57\u7b26\u4e32\u8d44\u6e90\uff0c\u518d\u7528 weight=1 \u4e14 width=0dp \u8ba9\u8f93\u5165\u6846\u94fa\u6ee1\u5269\u4f59\u7a7a\u95f4\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u7ae0\u8282\u6559\u4f60\u5982\u4f55\u5efa\u7acb\u7b2c\u4e00\u4e2a Android \u5e94\u7528\u7a0b\u5e8f\uff1a\u521b\u5efa\u9879\u76ee\u3001\u8fd0\u884c\u53ef\u8c03\u8bd5\u7248\u672c\uff0c\u4ee5\u53ca\u4e00\u4e9b\u5e94\u7528\u7a0b\u5e8f\u8bbe\u8ba1\u57fa\u7840\u2014\u2014\u521b\u5efa [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[52],"tags":[195],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/499"}],"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=499"}],"version-history":[{"count":3,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/499\/revisions"}],"predecessor-version":[{"id":3538,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/499\/revisions\/3538"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}