{"id":474,"date":"2023-08-26T10:11:55","date_gmt":"2024-02-12T06:38:07","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/index.php\/2023\/11\/30\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/"},"modified":"2025-08-02T12:22:15","modified_gmt":"2025-08-02T04:22:15","slug":"android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/","title":{"rendered":"Android\u5e03\u5c40\u5b8c\u5168\u6307\u5357\uff1a\u8be6\u89e3\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u4e0e\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)"},"content":{"rendered":"<p>\u8fd9\u662f\u6587\u7ae0\u300aAndroid\u5e03\u5c40 &#8211; \u7ebf\u6027\u5e03\u5c40\uff08LinearLayout\uff09\uff0c\u76f8\u5bf9\u5e03\u5c40\uff08RelativeLayout\uff09\u300b\u7684\u7b2c1\u90e8\u5206\uff08\u51714\u90e8\u5206\uff09\u3002<\/p>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u63d0\u4f9bAndroid\u5e03\u5c40\u7684\u6982\u8ff0\u3002\u6211\u4eec\u8fd8\u5c06\u63a2\u8ba8\u4e00\u4e9b\u4e13\u95e8\u7528\u4e8e\u7ec4\u7ec7\u5c4f\u5e55\u5185\u5bb9\u7684\u5e03\u5c40\u63a7\u4ef6\uff0c\u5373Android\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u548cAndroid\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)\u3002<\/p>\n<h2>Android\u5e03\u5c40<\/h2>\n<p>Android\u7528\u6237\u754c\u9762\u7684\u57fa\u672c\u6784\u5efa\u5757\u662f\u4eceView\u7c7b\u521b\u5efa\u7684View\u5bf9\u8c61\uff0c\u5360\u636e\u5c4f\u5e55\u4e0a\u7684\u77e9\u5f62\u533a\u57df\u3002View\u662fUI\u7ec4\u4ef6\u5982TextView\u3001Button\u3001EditText\u7b49\u7684\u57fa\u7c7b\u3002ViewGroup\u662fView\u7684\u5b50\u7c7b\u3002\u4e00\u4e2a\u6216\u591a\u4e2aView\u53ef\u4ee5\u88ab\u7ec4\u5408\u6210\u4e00\u4e2aViewGroup\u3002ViewGroup\u63d0\u4f9b\u4e86Android\u5e03\u5c40\uff0c\u6211\u4eec\u53ef\u4ee5\u5bf9\u89c6\u56fe\u7684\u5916\u89c2\u548c\u987a\u5e8f\u8fdb\u884c\u6392\u5217\u3002\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u3001\u6846\u67b6\u5e03\u5c40(FrameLayout)\u3001\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)\u7b49\u90fd\u662fViewGroup\u7684\u4f8b\u5b50\u3002<\/p>\n<h3>Android\u5e03\u5c40\u7c7b\u578b<\/h3>\n<p>\u5b89\u5353\u63d0\u4f9b\u4e86\u4ee5\u4e0b\u7684ViewGroups\u6216\u5e03\u5c40\uff1a<\/p>\n<ul>\n<li><strong>\u7ebf\u6027\u5e03\u5c40(LinearLayout)<\/strong>\uff1a\u662f\u4e00\u4e2a\u5e03\u5c40\u5bb9\u5668\uff0c\u5c06\u6240\u6709\u5b50\u89c6\u56fe\u5728\u4e00\u4e2a\u65b9\u5411\u4e0a\u8fdb\u884c\u5bf9\u9f50\uff0c\u53ef\u4ee5\u662f\u5782\u76f4\u6216\u6c34\u5e73\u5bf9\u9f50\u3002<\/li>\n<li><strong>\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)<\/strong>\uff1a\u662f\u4e00\u4e2a\u5e03\u5c40\u5bb9\u5668\uff0c\u4ee5\u76f8\u5bf9\u4f4d\u7f6e\u663e\u793a\u5b50\u89c6\u56fe\u3002<\/li>\n<li><strong>\u7edd\u5bf9\u5e03\u5c40(AbsoluteLayout)<\/strong>\uff1a\u5141\u8bb8\u6211\u4eec\u6307\u5b9a\u5b50\u89c6\u56fe\u548c\u5c0f\u90e8\u4ef6\u7684\u786e\u5207\u4f4d\u7f6e\u3002<\/li>\n<li><strong>\u8868\u683c\u5e03\u5c40(TableLayout)<\/strong>\uff1a\u662f\u4e00\u4e2a\u89c6\u56fe\uff0c\u5c06\u5176\u5b50\u89c6\u56fe\u5206\u7ec4\u6210\u884c\u548c\u5217\u3002<\/li>\n<li><strong>\u6846\u67b6\u5e03\u5c40(FrameLayout)<\/strong>\uff1a\u662f\u5c4f\u5e55\u4e0a\u7684\u5360\u4f4d\u7b26\uff0c\u7528\u4e8e\u663e\u793a\u5355\u4e2a\u89c6\u56fe\u3002<\/li>\n<li><strong>\u6eda\u52a8\u89c6\u56fe(ScrollView)<\/strong>\uff1a\u662f\u4e00\u79cd\u7279\u6b8a\u7c7b\u578b\u7684FrameLayout\uff0c\u5141\u8bb8\u7528\u6237\u6eda\u52a8\u6d4f\u89c8\u5360\u7528\u6bd4\u7269\u7406\u663e\u793a\u66f4\u591a\u7a7a\u95f4\u7684\u89c6\u56fe\u5217\u8868\u3002ScrollView\u53ea\u80fd\u5305\u542b\u4e00\u4e2a\u5b50\u89c6\u56fe\u6216ViewGroup\uff0c\u901a\u5e38\u662fLinearLayout\u3002<\/li>\n<li><strong>\u5217\u8868\u89c6\u56fe(ListView)<\/strong>\uff1a\u662f\u4e00\u4e2a\u89c6\u56fe\u7ec4\uff0c\u7528\u4e8e\u663e\u793a\u53ef\u6eda\u52a8\u7684\u5217\u8868\u9879\u3002<\/li>\n<li><strong>\u7f51\u683c\u89c6\u56fe(GridView)<\/strong>\uff1a\u662f\u4e00\u4e2a\u5e03\u5c40\u5bb9\u5668\uff0c\u4ee5\u4e8c\u7ef4\u6eda\u52a8\u7f51\u683c\u663e\u793a\u9879\u76ee\u3002\u7f51\u683c\u4e2d\u7684\u9879\u76ee\u6765\u81ea\u4e0e\u8be5\u89c6\u56fe\u5173\u8054\u7684ListAdapter\u3002<\/li>\n<\/ul>\n<p>\u5728\u8fd9\u4e2a\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4e13\u6ce8\u4e8e\u4e24\u4e2a\u6700\u5e38\u4f7f\u7528\u7684Android\u5e03\u5c40\uff1a<\/p>\n<ul>\n<li>\u7ebf\u6027\u5e03\u5c40(LinearLayout)<\/li>\n<li>\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)<\/li>\n<\/ul>\n<h3>Android\u5e03\u5c40\u5c5e\u6027<\/h3>\n<ul>\n<li><strong>android:id<\/strong>\uff1a\u8fd9\u662f\u552f\u4e00\u6807\u8bc6\u89c6\u56fe\u7684ID\u3002<\/li>\n<li><strong>android:layout_width<\/strong>\uff1a\u8fd9\u662f\u5e03\u5c40\u7684\u5bbd\u5ea6\u3002<\/li>\n<li><strong>android:layout_height<\/strong>\uff1a\u8fd9\u662f\u5e03\u5c40\u7684\u9ad8\u5ea6\u3002<\/li>\n<li><strong>android:layout_margin<\/strong>\uff1a\u8fd9\u662f\u89c6\u56fe\u5916\u90e8\u7684\u989d\u5916\u7a7a\u95f4\u3002\u4f8b\u5982\uff0c\u5982\u679c\u7ed9\u5b9aandroid:marginLeft=20dp\uff0c\u90a3\u4e48\u89c6\u56fe\u5c06\u5728\u79bb\u5de6\u4fa720dp\u4e4b\u540e\u5e03\u5c40\u3002<\/li>\n<li><strong>android:layout_padding<\/strong>\uff1a\u8fd9\u7c7b\u4f3c\u4e8eandroid:layout_margin\uff0c\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\u5b83\u6307\u5b9a\u4e86\u89c6\u56fe\u5185\u90e8\u7684\u989d\u5916\u7a7a\u95f4\u3002<\/li>\n<li><strong>android:layout_gravity<\/strong>\uff1a\u8fd9\u6307\u5b9a\u4e86\u5b50\u89c6\u56fe\u7684\u4f4d\u7f6e\u3002<\/li>\n<li><strong>android:layout_weight<\/strong>\uff1a\u8fd9\u6307\u5b9a\u4e86\u5e03\u5c40\u4e2d\u989d\u5916\u7a7a\u95f4\u5e94\u8be5\u5206\u914d\u7ed9\u89c6\u56fe\u7684\u5927\u5c0f\u3002<\/li>\n<li><strong>android:layout_x<\/strong>\uff1a\u8fd9\u6307\u5b9a\u4e86\u5e03\u5c40\u7684x\u5750\u6807\u3002<\/li>\n<li><strong>android:layout_y<\/strong>\uff1a\u8fd9\u6307\u5b9a\u4e86\u5e03\u5c40\u7684y\u5750\u6807\u3002<\/li>\n<\/ul>\n<p><code>android:layout_width=wrap_content<\/code> \u544a\u8bc9\u89c6\u56fe\u6839\u636e\u6240\u9700\u7684\u5185\u5bb9\u6765\u51b3\u5b9a\u81ea\u5df1\u7684\u5c3a\u5bf8\u3002<code>android:layout_width=match_parent<\/code> \u544a\u8bc9\u89c6\u56fe\u53d8\u5f97\u4e0e\u5176\u7236\u89c6\u56fe\u4e00\u6837\u5927\u3002<\/p>\n<h3>\u67e5\u770b\u8eab\u4efd\u8ba4\u8bc1<\/h3>\n<p>XML\u6807\u7b7e\u4e2d\u7684ID\u8bed\u6cd5\u4e3a\uff1a<\/p>\n<ul>\n<li>\u5b57\u7b26\u4e32\u5f00\u5934\u7684@\u7b26\u53f7\u8868\u793aXML\u89e3\u6790\u5668\u5e94\u8be5\u89e3\u6790\u5e76\u5c55\u5f00ID\u5b57\u7b26\u4e32\u7684\u5176\u4f59\u90e8\u5206\uff0c\u5e76\u5c06\u5176\u6807\u8bc6\u4e3aID\u8d44\u6e90\u3002<\/li>\n<li>\u52a0\u53f7(+)\u8868\u793a\u8fd9\u662f\u4e00\u4e2a\u65b0\u7684\u8d44\u6e90\u540d\u79f0\uff0c\u5fc5\u987b\u521b\u5efa\u5e76\u6dfb\u52a0\u5230\u6211\u4eec\u7684\u8d44\u6e90\u4e2d\u3002<\/li>\n<\/ul>\n<h3>\u5b89\u5353(Android)\u7ebf\u6027\u5e03\u5c40(LinearLayout)<\/h3>\n<p>Android\u7684LinearLayout\u5c06\u5143\u7d20\u6cbf\u4e00\u6761\u76f4\u7ebf\u8fdb\u884c\u7ec4\u7ec7\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528android:orientation\u6765\u6307\u5b9a\u8be5\u7ebf\u662f\u5782\u76f4\u8fd8\u662f\u6c34\u5e73\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u65b9\u5411\u662f\u6c34\u5e73\u7684\u3002\u5782\u76f4LinearLayout\u6bcf\u884c\u53ea\u6709\u4e00\u4e2a\u5b50\u5143\u7d20\uff08\u56e0\u6b64\u662f\u5355\u4e2a\u5143\u7d20\u7684\u5217\uff09\uff0c\u800c\u6c34\u5e73LinearLayout\u5728\u5c4f\u5e55\u4e0a\u53ea\u6709\u4e00\u884c\u5355\u4e2a\u5143\u7d20\u3002android:layout_weight\u5c5e\u6027\u63cf\u8ff0\u4e86\u5143\u7d20\u7684\u91cd\u8981\u6027\u3002\u5177\u6709\u8f83\u5927\u6743\u91cd\u7684\u5143\u7d20\u5360\u7528\u66f4\u591a\u7684\u5c4f\u5e55\u7a7a\u95f4\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528LinearLayout\u7684\u793a\u4f8b\u5e03\u5c40XML\uff1alayout_linear.xml<\/p>\n<pre class=\"post-pre\"><code>&lt;LinearLayout xmlns:android=\"https:\/\/schemas.android.com\/apk\/res\/android\"\r\n    android:orientation=\"vertical\"\r\n    android:layout_width=\"fill_parent\"\r\n    android:layout_height=\"fill_parent\"\r\n    android:layout_margin=\"@dimen\/activity_horizontal_margin\"&gt;\r\n    &lt;Button\r\n        android:id=\"@+id\/backbutton\"\r\n        android:text=\"Back\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\" \/&gt;\r\n    &lt;TextView\r\n        android:text=\"Row 2\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:textSize=\"18sp\"\r\n        android:layout_margin=\"10dp\"\r\n        android:layout_height=\"wrap_content\" \/&gt;\r\n    &lt;TextView\r\n        android:text=\"Row 3\"\r\n        android:textSize=\"18sp\"\r\n        android:layout_margin=\"10dp\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\" \/&gt;\r\n    &lt;TextView\r\n        android:text=\"Row 4\"\r\n        android:textSize=\"18sp\"\r\n        android:layout_margin=\"10dp\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\" \/&gt;\r\n    &lt;TextView\r\n        android:text=\"Row 5\"\r\n        android:textSize=\"18sp\"\r\n        android:layout_margin=\"10dp\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\" \/&gt;\r\n\r\n    &lt;LinearLayout\r\n        android:orientation=\"horizontal\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"&gt;\r\n        &lt;Button\r\n            android:id=\"@+id\/next_button\"\r\n            android:text=\"next\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\" \/&gt;\r\n        &lt;TextView\r\n            android:text=\"Row 6b\"\r\n            android:textSize=\"18sp\"\r\n            android:layout_margin=\"10dp\"\r\n            android:layout_gravity=\"center\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\" \/&gt;\r\n        &lt;TextView\r\n            android:text=\"Row 6c\"\r\n            android:textSize=\"18sp\"\r\n            android:layout_margin=\"10dp\"\r\n            android:layout_gravity=\"center\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\" \/&gt;\r\n        &lt;TextView\r\n            android:text=\"Row 6d\"\r\n            android:textSize=\"18sp\"\r\n            android:layout_margin=\"10dp\"\r\n            android:layout_gravity=\"center\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\" \/&gt;\r\n\r\n    &lt;\/LinearLayout&gt;\r\n\r\n&lt;\/LinearLayout&gt;\r\n<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u5e03\u5c40\u4e2d\uff0c\u6211\u4eec\u6709\u4e00\u4e2a\u7236LinearLayout\uff0c\u5b83\u5177\u6709\u5782\u76f4\u65b9\u5411\uff0c\u5e76\u5305\u542b\u6309\u94ae\u3001\u6587\u672c\u89c6\u56fe\u548c\u4e00\u4e2a\u5d4c\u5957\u7684LinearLayout\uff08\u5177\u6709\u6c34\u5e73\u65b9\u5411\uff09\u4f5c\u4e3a\u5b50\u89c6\u56fe\u3002\u6ce8\u610f\uff1a\u5d4c\u5957\u7684\u5e03\u5c40\u4e0d\u9700\u8981\u662f\u76f8\u540c\u7c7b\u578b\u7684\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u5728RelativeLayout\u7684\u5b50\u89c6\u56fe\u4e2d\u6709\u4e00\u4e2aLinearLayout\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002<\/p>\n<h3>\u5b89\u5353\u7684RelativeLayoutAndroid\u7684RelativeLayout\u662f\u6839\u636e\u5143\u7d20\u4e4b\u95f4\u7684\u5173\u7cfb\u4ee5\u53ca\u4e0e\u7236\u5bb9\u5668\u7684\u5173\u7cfb\u6765\u8fdb\u884c\u5e03\u5c40\u7684\u3002\u8fd9\u662f\u6700\u590d\u6742\u7684\u5e03\u5c40\u4e4b\u4e00\uff0c\u6211\u4eec\u9700\u8981\u591a\u4e2a\u5c5e\u6027\u6765\u5b9e\u73b0\u6211\u4eec\u60f3\u8981\u7684\u5e03\u5c40\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u4f7f\u7528RelativeLayout\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u4e00\u4e2a\u89c6\u56fe\u653e\u7f6e\u5728\u5176\u5144\u5f1f\u89c6\u56fe\u7684\u5de6\u4fa7\u3001\u53f3\u4fa7\u3001\u4e0b\u65b9\u6216\u4e0a\u65b9\u3002\u6211\u4eec\u8fd8\u53ef\u4ee5\u6839\u636e\u7236\u89c6\u56fe\u6765\u5b9a\u4f4d\u4e00\u4e2a\u89c6\u56fe\uff0c\u4f8b\u5982\u6c34\u5e73\u3001\u5782\u76f4\u6216\u4e24\u8005\u5c45\u4e2d\uff0c\u6216\u8005\u4e0e\u7236RelativeLayout\u7684\u4efb\u4f55\u8fb9\u5bf9\u9f50\u3002\u5982\u679c\u5728\u5b50\u89c6\u56fe\u4e0a\u6ca1\u6709\u6307\u5b9a\u8fd9\u4e9b\u5c5e\u6027\u4e2d\u7684\u4efb\u4f55\u4e00\u4e2a\uff0c\u90a3\u4e48\u8be5\u89c6\u56fe\u9ed8\u8ba4\u5448\u73b0\u5728\u5de6\u4e0a\u89d2\u4f4d\u7f6e\u4e0a\u3002<\/p>\n<h3>\u5b89\u5353\u7684RelativeLayout\u5c5e\u6027\u4ee5\u4e0b\u662f\u5728RelativeLayout\u4e2d\u4f7f\u7528\u7684\u4e3b\u8981\u5c5e\u6027\u3002\u5b83\u4eec\u5206\u5c5e\u4e8e\u4e09\u4e2a\u4e0d\u540c\u7684\u7c7b\u522b\u3002<\/p>\n<h4>\u5173\u4e8e\u5bb9\u5668<\/p>\n<ul class=\"post-ul\">\n<li>android:layout_alignParentBottom : Places the bottom of the element on the bottom of the container<\/li>\n<li>android:layout_alignParentLeft : Places the left of the element on the left side of the container<\/li>\n<li>android:layout_alignParentRight : Places the right of the element on the right side of the container<\/li>\n<li>android:layout_alignParentTop : Places the element at the top of the container<\/li>\n<li>android:layout_centerHorizontal : Centers the element horizontally within its parent container<\/li>\n<li>android:layout_centerInParent : Centers the element both horizontally and vertically within its container<\/li>\n<li>android:layout_centerVertical : Centers the element vertically within its parent container<\/li>\n<\/ul>\n<h4>\u76f8\u5bf9\u4e8e\u5144\u5f1f\u59d0\u59b9<\/p>\n<ul class=\"post-ul\">\n<li>android:layout_above : Places the element above the specified element<\/li>\n<li>android:layout_below : Places the element below the specified element<\/li>\n<li>android:layout_toLeftOf : Places the element to the left of the specified element<\/li>\n<li>android:layout_toRightOf : Places the element to the right of the specified element<\/li>\n<\/ul>\n<p>\u201c@id\/XXXXX\u201d \u662f\u7528\u6765\u901a\u8fc7\u5143\u7d20\u7684 id \u8fdb\u884c\u5f15\u7528\u3002\u9700\u8981\u8bb0\u4f4f\u7684\u4e00\u4ef6\u4e8b\u662f\uff0c\u5728\u5143\u7d20\u88ab\u58f0\u660e\u4e4b\u524d\u5f15\u7528\u5b83\u4f1a\u4ea7\u751f\u9519\u8bef\uff0c\u56e0\u6b64\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5e94\u8be5\u4f7f\u7528 @+id\/\u3002<\/p>\n<h4>\u4e0e\u5176\u4ed6\u5143\u7d20\u7684\u534f\u8c03<\/p>\n<ul class=\"post-ul\">\n<li>android:layout_alignBaseline : \u5c06\u65b0\u5143\u7d20\u7684\u57fa\u7ebf\u4e0e\u6307\u5b9a\u5143\u7d20\u7684\u57fa\u7ebf\u5bf9\u9f50<\/li>\n<li>android:layout_alignBottom : \u5c06\u65b0\u5143\u7d20\u7684\u5e95\u90e8\u4e0e\u6307\u5b9a\u5143\u7d20\u7684\u5e95\u90e8\u5bf9\u9f50<\/li>\n<li>android:layout_alignLeft : \u5c06\u65b0\u5143\u7d20\u7684\u5de6\u8fb9\u7f18\u4e0e\u6307\u5b9a\u5143\u7d20\u7684\u5de6\u8fb9\u7f18\u5bf9\u9f50<\/li>\n<li>android:layout_alignRight : \u5c06\u65b0\u5143\u7d20\u7684\u53f3\u8fb9\u7f18\u4e0e\u6307\u5b9a\u5143\u7d20\u7684\u53f3\u8fb9\u7f18\u5bf9\u9f50<\/li>\n<li>android:layout_alignTop : \u5c06\u65b0\u5143\u7d20\u7684\u9876\u90e8\u4e0e\u6307\u5b9a\u5143\u7d20\u7684\u9876\u90e8\u5bf9\u9f50<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u7684XML\u5e03\u5c40\u4f7f\u7528\u4e86\u76f8\u5bf9\u5e03\u5c40\uff08RelativeLayout\uff09\uff1alayout_relative.xml<\/p>\n<pre class=\"post-pre\"><code>&lt;RelativeLayout\r\n    android:layout_width=\"fill_parent\"\r\n    android:layout_height=\"fill_parent\"\r\n    xmlns:android=\"https:\/\/schemas.android.com\/apk\/res\/android\"&gt;\r\n    &lt;Button\r\n        android:id=\"@+id\/backbutton\"\r\n        android:text=\"\u8fd4\u56de\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\" \/&gt;\r\n    &lt;TextView\r\n        android:id=\"@+id\/firstName\"\r\n        android:text=\"\u540d\u5b57\"\r\n        android:textSize=\"18sp\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_below=\"@id\/backbutton\" \/&gt;\r\n    &lt;TextView\r\n        android:id=\"@+id\/editFirstName\"\r\n        android:text=\"\u5f00\u53d1\u793a\u4f8b\"\r\n        android:textSize=\"18sp\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_marginLeft=\"10dp\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_toRightOf=\"@id\/firstName\"\r\n        android:layout_below=\"@id\/backbutton\"\/&gt;\r\n    &lt;TextView\r\n        android:id=\"@+id\/editLastName\"\r\n        android:text=\"\u5e03\u5c40\u6559\u7a0b\u793a\u4f8b\"\r\n        android:textSize=\"18sp\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_alignTop=\"@+id\/lastName\"\r\n        android:layout_toRightOf=\"@+id\/lastName\"\r\n        android:layout_toEndOf=\"@+id\/lastName\" \/&gt;\r\n    &lt;TextView\r\n        android:id=\"@+id\/lastName\"\r\n        android:text=\"\u59d3\u6c0f\"\r\n        android:textSize=\"18sp\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_marginTop=\"48dp\"\r\n        android:layout_below=\"@+id\/firstName\"\r\n        android:layout_alignParentLeft=\"true\"\r\n        android:layout_alignParentStart=\"true\"\r\n        android:layout_marginRight=\"10dp\"\r\n        android:layout_marginLeft=\"40dp\"\r\n        android:layout_marginStart=\"40dp\" \/&gt;\r\n\r\n    &lt;Button\r\n        android:id=\"@+id\/next\"\r\n        android:text=\"\u4e0b\u4e00\u6b65\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:layout_below=\"@+id\/editLastName\"\r\n        android:layout_alignLeft=\"@+id\/editLastName\"\r\n        android:layout_alignStart=\"@+id\/editLastName\"\r\n        android:layout_marginTop=\"37dp\" \/&gt;\r\n&lt;\/RelativeLayout&gt;\r\n<\/code><\/pre>\n<p>\u6b63\u5982\u4f60\u6240\u770b\u5230\u7684\uff0c\u6211\u4eec\u53ef\u4ee5\u6839\u636e\u5143\u7d20\u7684\u76f8\u5bf9\u4f4d\u7f6e\u91cd\u65b0\u6392\u5217\u5b83\u4eec\u3002\u4e0b\u9762\u7684XML\u5e03\u5c40\u4ee3\u8868\u4e86\u4e00\u4e2a\u5177\u6709\u5d4c\u5957\u7684\u7ebf\u6027\u5e03\u5c40\u548c\u76f8\u5bf9\u5e03\u5c40\u7684\u81ea\u5b9a\u4e49\u5e03\u5c40\u3002layout_mixed.xml<\/p>\n<pre class=\"post-pre\"><code>&lt;RelativeLayout\r\n    android:layout_width=\"fill_parent\"\r\n    android:layout_height=\"fill_parent\"\r\n    xmlns:android=\"https:\/\/schemas.android.com\/apk\/res\/android\"&gt;\r\n\r\n    &lt;TextView\r\n        android:id=\"@+id\/parent_rl\"\r\n        android:text=\"\u7236\u7ea7\u76f8\u5bf9\u5e03\u5c40\"\r\n        android:textSize=\"18sp\"\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\" \/&gt;\r\n\r\n    &lt;LinearLayout\r\n        android:orientation=\"horizontal\"\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:id=\"@+id\/linearLayout\"\r\n        android:layout_below=\"@id\/parent_rl\"\r\n        android:layout_alignParentRight=\"true\"\r\n        android:layout_alignParentEnd=\"true\"&gt;\r\n\r\n        &lt;TextView\r\n            android:text=\"\u5d4c\u5957\u6c34\u5e73\u5e03\u5c40\"\r\n            android:textSize=\"18sp\"\r\n            android:layout_margin=\"10dp\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\" \/&gt;\r\n\r\n        &lt;TextView\r\n            android:text=\"\u7ebf\u6027\u5e03\u5c40\"\r\n            android:textSize=\"18sp\"\r\n            android:layout_margin=\"10dp\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\" \/&gt;\r\n\r\n\r\n        &lt;LinearLayout\r\n            android:orientation=\"vertical\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"&gt;\r\n\r\n            &lt;TextView\r\n                android:text=\"\u53cc\u91cd\u5d4c\u5957\"\r\n                android:textSize=\"18sp\"\r\n                android:layout_margin=\"10dp\"\r\n                android:layout_gravity=\"center\"\r\n                android:layout_width=\"wrap_content\"\r\n                android:layout_height=\"wrap_content\" \/&gt;\r\n            &lt;TextView\r\n                android:text=\"\u5782\u76f4\u5e03\u5c40\"\r\n                android:textSize=\"18sp\"\r\n                android:layout_margin=\"10dp\"\r\n                android:layout_gravity=\"center\"\r\n                android:layout_width=\"wrap_content\"\r\n                android:layout_height=\"wrap_content\" \/&gt;\r\n            &lt;TextView\r\n                android:text=\"\u7ebf\u6027\u5e03\u5c40\"\r\n                android:textSize=\"18sp\"\r\n                android:layout_margin=\"10dp\"\r\n                android:layout_gravity=\"center\"\r\n                android:layout_width=\"wrap_content\"\r\n                android:layout_height=\"wrap_content\" \/&gt;\r\n\r\n        &lt;\/LinearLayout&gt;\r\n\r\n\r\n    &lt;\/LinearLayout&gt;\r\n\r\n    &lt;RelativeLayout\r\n        android:layout_width=\"match_parent\"\r\n        android:layout_height=\"match_parent\"\r\n        android:layout_below=\"@id\/linearLayout\"&gt;\r\n\r\n    &lt;TextView\r\n        android:layout_width=\"wrap_content\"\r\n        android:layout_height=\"wrap_content\"\r\n        android:textAppearance=\"?android:attr\/textAppearanceMedium\"\r\n        android:text=\"\u5d4c\u5957\u76f8\u5bf9\u5e03\u5c40\"\r\n        android:id=\"@+id\/textView\"\r\n        android:layout_alignParentTop=\"true\"\r\n        android:layout_centerHorizontal=\"true\" \/&gt;\r\n\r\n        &lt;Button\r\n            android:id=\"@+id\/back_button_pressed\"\r\n            android:text=\"\u8fd4\u56de\"\r\n            android:layout_width=\"wrap_content\"\r\n            android:layout_height=\"wrap_content\"\r\n            android:layout_below=\"@+id\/textView\"\r\n            android:layout_centerHorizontal=\"true\"\r\n            android:layout_marginTop=\"66dp\" \/&gt;\r\n\r\n    &lt;\/RelativeLayout&gt;\r\n\r\n\r\n&lt;\/RelativeLayout&gt;\r\n<\/code><\/pre>\n<h3>Android\u5e03\u5c40\u9879\u76ee\u7ed3\u6784<\/h3>\n<h3>Android\u5e03\u5c40\u9879\u76ee\u5b9e\u73b0<\/h3>\n<p>\u8be5\u9879\u76ee\u5305\u542b\u4e09\u4e2aActivity\uff08\u6d3b\u52a8\uff09\u4ee5\u53ca\u524d\u9762\u8ba8\u8bba\u8fc7\u7684\u76f8\u5e94\u5e03\u5c40\u3002<\/p>\n<h3>Android\u5e03\u5c40\u4ee3\u7801\u5b9e\u73b0<\/h3>\n<p>\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u65f6\u8fdb\u5165MainActivity\uff0c\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u52a0\u8f7dlayout_linear.xml\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9\uff1a<\/p>\n<pre class=\"post-pre\"><code>package com.Olivia.layouts;\r\n\r\nimport android.content.Intent;\r\nimport android.support.v7.app.AppCompatActivity;\r\nimport android.os.Bundle;\r\nimport android.view.Menu;\r\nimport android.view.MenuItem;\r\nimport android.view.View;\r\nimport android.widget.Button;\r\n\r\npublic class MainActivity extends AppCompatActivity {\r\n\r\n\r\n    Button back,next;\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.layout_linear);\r\n        back=(Button)findViewById(R.id.back_button);\r\n        next=(Button)findViewById(R.id.next_button);\r\n\r\n        next.setOnClickListener(new View.OnClickListener() {\r\n            @Override\r\n            public void onClick(View v) {\r\n                Intent intent=new Intent(MainActivity.this,SecondActivity.class);\r\n                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);\r\n                startActivity(intent);\r\n            }\r\n        });\r\n        back.setOnClickListener(new View.OnClickListener() {\r\n            @Override\r\n            public void onClick(View v) {\r\n                finish();\r\n            }\r\n        });\r\n\r\n    }\r\n\r\n}\r\n<\/code><\/pre>\n<p>\u7b2c\u4e8c\u4e2aActivity\uff08SecondActivity\uff09\u548c\u7b2c\u4e09\u4e2aActivity\uff08ThirdActivity\uff09\u5206\u522b\u52a0\u8f7dlayout_relative.xml\u548clayout_mixed.xml\u5e03\u5c40\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre class=\"post-pre\"><code>package com.Olivia.layouts;\r\n\r\nimport android.app.Activity;\r\nimport android.content.Intent;\r\nimport android.os.Bundle;\r\nimport android.view.View;\r\nimport android.widget.Button;\r\n\r\npublic class SecondActivity extends Activity {\r\n    Button back,next;\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.layout_relative);\r\n        back=(Button)findViewById(R.id.backbutton);\r\n        next=(Button)findViewById(R.id.next);\r\n\r\n        next.setOnClickListener(new View.OnClickListener() {\r\n            @Override\r\n            public void onClick(View v) {\r\n                Intent intent=new Intent(SecondActivity.this,ThirdActivity.class);\r\n                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);\r\n                startActivity(intent);\r\n            }\r\n        });\r\n        back.setOnClickListener(new View.OnClickListener() {\r\n            @Override\r\n            public void onClick(View v) {\r\n                Intent intent=new Intent(SecondActivity.this,MainActivity.class);\r\n                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);\r\n                startActivity(intent);\r\n            }\r\n        });\r\n\r\n    }\r\n}\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>package com.Olivia.layouts;\r\n\r\nimport android.app.Activity;\r\nimport android.content.Intent;\r\nimport android.os.Bundle;\r\nimport android.view.View;\r\nimport android.widget.Button;\r\n\r\npublic class ThirdActivity extends Activity {\r\n    Button back;\r\n    @Override\r\n    protected void onCreate(Bundle savedInstanceState) {\r\n        super.onCreate(savedInstanceState);\r\n        setContentView(R.layout.layout_mixed);\r\n        back=(Button)findViewById(R.id.back_button_pressed);\r\n\r\n        back.setOnClickListener(new View.OnClickListener() {\r\n            @Override\r\n            public void onClick(View v) {\r\n                Intent intent=new Intent(ThirdActivity.this,SecondActivity.class);\r\n                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);\r\n                startActivity(intent);\r\n            }\r\n        });\r\n\r\n    }\r\n}\r\n<\/code><\/pre>\n<h3>\u5e03\u5c40\u6587\u4ef6\u6548\u679c\u5c55\u793a<\/h3>\n<p>\u4e0b\u9762\u5c55\u793a\u4e86\u4e09\u4e2a\u5e03\u5c40\u6587\u4ef6\u7684\u56fe\u50cf\u8f93\u51fa\uff1a<\/p>\n<p><strong>layout_linear.xml<\/strong> \u53ef\u4ee5\u770b\u5230\uff0c\u7236LinearLayout\u75316\u4e2a\u5b50\u5143\u7d20\u7ec4\u6210\uff0c\u4f4d\u4e8e\u4e00\u4e2a\u5782\u76f4\u5217\u4e2d\uff0c\u5176\u4e2d\u4e00\u4e2a\u662f\u5305\u542b4\u4e2a\u6c34\u5e73\u65b9\u5411\u7ec4\u4ef6\u7684\u5d4c\u5957LinearLayout\u5b50\u89c6\u56fe\u3002<\/p>\n<p><strong>layout_relative.xml<\/strong> \u4e0a\u9762\u56fe\u50cf\u4e2d\u7684\u7bad\u5934\u63cf\u8ff0\u4e86\u5144\u5f1f\u5143\u7d20\u76f8\u5bf9\u4e8e\u5f7c\u6b64\u548c\u5bb9\u5668\u7684\u4f4d\u7f6e\u3002<\/p>\n<p><strong>layout_mixed.xml<\/strong> \u8fd9\u4e2a\u76f8\u5bf9\u5e03\u5c40\u5305\u542b\u4e00\u4e2a\u5782\u76f4LinearLayout\u548c\u4e00\u4e2a\u5d4c\u5957\u7684\u6c34\u5e73LinearLayout\uff0c\u4ee5\u53ca\u4e00\u4e2a\u5b50RelativeLayout\u3002\u6ce8\u610f\uff1a\u5c5e\u4e8e\u4e0d\u540c\u5e03\u5c40\u7684\u7ec4\u4ef6\u4e0d\u662f\u5144\u5f1f\u5143\u7d20\uff0c\u56e0\u6b64\u4e0d\u80fd\u76f8\u5bf9\u4e8e\u5f7c\u6b64\u5b9a\u4f4d\u3002\u5b83\u4eec\u7684\u5bb9\u5668\u5e03\u5c40\u662f\u5144\u5f1f\u5143\u7d20\uff0c\u53ef\u4ee5\u76f8\u5bf9\u4e8e\u5f7c\u6b64\u5b9a\u4f4d\u3002\u5982\u679c\u4f60\u60f3\u77e5\u9053\u84dd\u8272\u8fb9\u6846\u77e9\u5f62\u548c\u7bad\u5934\u662f\u4ec0\u4e48\uff0c\u90a3\u662f\u56e0\u4e3a\u8fd9\u4e9b\u56fe\u7247\u6765\u81ea\u56fe\u5f62\u89c6\u56fe\u4e2d\u7684xml\u5e03\u5c40\u3002\u5f53\u4f60\u8fd0\u884c\u5e94\u7528\u65f6\uff0c\u8fd9\u4e9b\u84dd\u8272\u7ebf\u6761\u548c\u77e9\u5f62\u5c06\u4e0d\u4f1a\u663e\u793a\u3002<\/p>\n<h3>\u603b\u7ed3\u4e0e\u540e\u7eed<\/h3>\n<p>\u8fd9\u5c31\u662fAndroid\u5e03\u5c40\u6559\u7a0b\u7684\u7ed3\u675f\u3002\u6211\u4eec\u5c06\u5728\u4e0b\u4e00\u4e2a\u6559\u7a0b\u4e2d\u4ecb\u7ecd\u5176\u4ed6Android\u5e03\u5c40\u3002\u4f60\u53ef\u4ee5\u4ece\u4e0b\u9762\u7684\u94fe\u63a5\u4e0b\u8f7d\u6700\u7ec8\u7684Android\u5e03\u5c40\u9879\u76ee\u3002<\/p>\n<p>\u4e0b\u8f7d Android LinearLayout RelativeLayout \u793a\u4f8b\u9879\u76ee\u3002<\/p>\n<p>\u53c2\u8003\uff1aAPI\u6587\u6863<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u6587\u7ae0\u300aAndroid\u5e03\u5c40 &#8211; \u7ebf\u6027\u5e03\u5c40\uff08LinearLayout\uff09\uff0c\u76f8\u5bf9\u5e03\u5c40\uff08Relative [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1449,900,1450,1451,902],"class_list":{"0":"post-474","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-uncategorized","7":"tag-android","9":"tag-linearlayout","10":"tag-relativelayout","11":"tag-ui"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Android\u5e03\u5c40\u5b8c\u5168\u6307\u5357\uff1a\u8be6\u89e3\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u4e0e\u76f8\u5bf9\u5e03\u5c40(RelativeLayout) - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"\u672c\u6587\u8be6\u7ec6\u89e3\u6790Android\u5f00\u53d1\u4e2d\u4e24\u79cd\u6838\u5fc3\u5e03\u5c40\uff1a\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u548c\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)\u3002\u901a\u8fc7\u5b9e\u4f8b\u4ee3\u7801\u548c\u56fe\u89e3\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u638c\u63e1\u5e03\u5c40\u5c5e\u6027\u3001\u4f7f\u7528\u573a\u666f\u53ca\u6700\u4f73\u5b9e\u8df5\uff0c\u63d0\u5347Android\u5e94\u7528UI\u8bbe\u8ba1\u6548\u7387\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/android\u5e03\u5c40-\u7ebf\u6027\u5e03\u5c40\uff08linearlayout\uff09\uff0c\u76f8\u5bf9\u5e03\u5c40\uff08relativelayout\uff09\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Android\u5e03\u5c40\u5b8c\u5168\u6307\u5357\uff1a\u8be6\u89e3\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u4e0e\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)\" \/>\n<meta property=\"og:description\" content=\"\u672c\u6587\u8be6\u7ec6\u89e3\u6790Android\u5f00\u53d1\u4e2d\u4e24\u79cd\u6838\u5fc3\u5e03\u5c40\uff1a\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u548c\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)\u3002\u901a\u8fc7\u5b9e\u4f8b\u4ee3\u7801\u548c\u56fe\u89e3\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u638c\u63e1\u5e03\u5c40\u5c5e\u6027\u3001\u4f7f\u7528\u573a\u666f\u53ca\u6700\u4f73\u5b9e\u8df5\uff0c\u63d0\u5347Android\u5e94\u7528UI\u8bbe\u8ba1\u6548\u7387\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/android\u5e03\u5c40-\u7ebf\u6027\u5e03\u5c40\uff08linearlayout\uff09\uff0c\u76f8\u5bf9\u5e03\u5c40\uff08relativelayout\uff09\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-12T06:38:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-02T04:22:15+00:00\" \/>\n<meta name=\"author\" content=\"\u5b87, \u534e\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5b87, \u534e\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/\",\"name\":\"Android\u5e03\u5c40\u5b8c\u5168\u6307\u5357\uff1a\u8be6\u89e3\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u4e0e\u76f8\u5bf9\u5e03\u5c40(RelativeLayout) - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2024-02-12T06:38:07+00:00\",\"dateModified\":\"2025-08-02T04:22:15+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\"},\"description\":\"\u672c\u6587\u8be6\u7ec6\u89e3\u6790Android\u5f00\u53d1\u4e2d\u4e24\u79cd\u6838\u5fc3\u5e03\u5c40\uff1a\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u548c\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)\u3002\u901a\u8fc7\u5b9e\u4f8b\u4ee3\u7801\u548c\u56fe\u89e3\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u638c\u63e1\u5e03\u5c40\u5c5e\u6027\u3001\u4f7f\u7528\u573a\u666f\u53ca\u6700\u4f73\u5b9e\u8df5\uff0c\u63d0\u5347Android\u5e94\u7528UI\u8bbe\u8ba1\u6548\u7387\u3002\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Android\u5e03\u5c40\u5b8c\u5168\u6307\u5357\uff1a\u8be6\u89e3\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u4e0e\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\",\"name\":\"\u5b87, \u534e\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"caption\":\"\u5b87, \u534e\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Android\u5e03\u5c40\u5b8c\u5168\u6307\u5357\uff1a\u8be6\u89e3\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u4e0e\u76f8\u5bf9\u5e03\u5c40(RelativeLayout) - Blog - Silicon Cloud","description":"\u672c\u6587\u8be6\u7ec6\u89e3\u6790Android\u5f00\u53d1\u4e2d\u4e24\u79cd\u6838\u5fc3\u5e03\u5c40\uff1a\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u548c\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)\u3002\u901a\u8fc7\u5b9e\u4f8b\u4ee3\u7801\u548c\u56fe\u89e3\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u638c\u63e1\u5e03\u5c40\u5c5e\u6027\u3001\u4f7f\u7528\u573a\u666f\u53ca\u6700\u4f73\u5b9e\u8df5\uff0c\u63d0\u5347Android\u5e94\u7528UI\u8bbe\u8ba1\u6548\u7387\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/android\u5e03\u5c40-\u7ebf\u6027\u5e03\u5c40\uff08linearlayout\uff09\uff0c\u76f8\u5bf9\u5e03\u5c40\uff08relativelayout\uff09\/","og_locale":"zh_CN","og_type":"article","og_title":"Android\u5e03\u5c40\u5b8c\u5168\u6307\u5357\uff1a\u8be6\u89e3\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u4e0e\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)","og_description":"\u672c\u6587\u8be6\u7ec6\u89e3\u6790Android\u5f00\u53d1\u4e2d\u4e24\u79cd\u6838\u5fc3\u5e03\u5c40\uff1a\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u548c\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)\u3002\u901a\u8fc7\u5b9e\u4f8b\u4ee3\u7801\u548c\u56fe\u89e3\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u638c\u63e1\u5e03\u5c40\u5c5e\u6027\u3001\u4f7f\u7528\u573a\u666f\u53ca\u6700\u4f73\u5b9e\u8df5\uff0c\u63d0\u5347Android\u5e94\u7528UI\u8bbe\u8ba1\u6548\u7387\u3002","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/android\u5e03\u5c40-\u7ebf\u6027\u5e03\u5c40\uff08linearlayout\uff09\uff0c\u76f8\u5bf9\u5e03\u5c40\uff08relativelayout\uff09\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2024-02-12T06:38:07+00:00","article_modified_time":"2025-08-02T04:22:15+00:00","author":"\u5b87, \u534e","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5b87, \u534e","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/","name":"Android\u5e03\u5c40\u5b8c\u5168\u6307\u5357\uff1a\u8be6\u89e3\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u4e0e\u76f8\u5bf9\u5e03\u5c40(RelativeLayout) - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2024-02-12T06:38:07+00:00","dateModified":"2025-08-02T04:22:15+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458"},"description":"\u672c\u6587\u8be6\u7ec6\u89e3\u6790Android\u5f00\u53d1\u4e2d\u4e24\u79cd\u6838\u5fc3\u5e03\u5c40\uff1a\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u548c\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)\u3002\u901a\u8fc7\u5b9e\u4f8b\u4ee3\u7801\u548c\u56fe\u89e3\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u638c\u63e1\u5e03\u5c40\u5c5e\u6027\u3001\u4f7f\u7528\u573a\u666f\u53ca\u6700\u4f73\u5b9e\u8df5\uff0c\u63d0\u5347Android\u5e94\u7528UI\u8bbe\u8ba1\u6548\u7387\u3002","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"Android\u5e03\u5c40\u5b8c\u5168\u6307\u5357\uff1a\u8be6\u89e3\u7ebf\u6027\u5e03\u5c40(LinearLayout)\u4e0e\u76f8\u5bf9\u5e03\u5c40(RelativeLayout)"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458","name":"\u5b87, \u534e","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","caption":"\u5b87, \u534e"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/android%e5%b8%83%e5%b1%80-%e7%ba%bf%e6%80%a7%e5%b8%83%e5%b1%80%ef%bc%88linearlayout%ef%bc%89%ef%bc%8c%e7%9b%b8%e5%af%b9%e5%b8%83%e5%b1%80%ef%bc%88relativelayout%ef%bc%89\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/474","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=474"}],"version-history":[{"count":4,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/474\/revisions"}],"predecessor-version":[{"id":110111,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/474\/revisions\/110111"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}