{"id":458,"date":"2012-10-17T15:34:44","date_gmt":"2012-10-17T15:34:44","guid":{"rendered":"http:\/\/ahsiu.com\/?p=458"},"modified":"2012-10-17T15:34:44","modified_gmt":"2012-10-17T15:34:44","slug":"android-ui%e5%b8%83%e5%b1%80%e5%b8%b8%e8%a7%81%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/blog.xiunian.wang\/?p=458","title":{"rendered":"android UI\u5e03\u5c40\u5e38\u89c1\u95ee\u9898"},"content":{"rendered":"<h1>1.Android fill_parent\u3001wrap_content\u548cmatch_parent\u7684\u533a\u522b<\/h1>\n<p>\u4e09\u4e2a\u5c5e\u6027\u90fd\u7528\u6765\u9002\u5e94\u89c6\u56fe\u7684\u6c34\u5e73\u6216\u5782\u76f4\u5927\u5c0f\uff0c\u4e00\u4e2a\u4ee5\u89c6\u56fe\u7684\u5185\u5bb9\u6216\u5c3a\u5bf8\u4e3a\u57fa\u7840\u7684\u5e03\u5c40\u6bd4\u7cbe\u786e\u5730\u6307\u5b9a\u89c6\u56fe\u8303\u56f4\u66f4\u52a0\u65b9\u4fbf\u3002<\/p>\n<p><strong>1\uff09fill_parent<\/strong><\/p>\n<p>\u8bbe\u7f6e\u4e00\u4e2a\u6784\u4ef6\u7684\u5e03\u5c40\u4e3afill_parent\u5c06\u5f3a\u5236\u6027\u5730\u4f7f\u6784\u4ef6\u6269\u5c55\uff0c\u4ee5\u586b\u5145\u5e03\u5c40\u5355\u5143\u5185\u5c3d\u53ef\u80fd\u591a\u7684\u7a7a\u95f4\u3002\u8fd9\u8ddfWindows\u63a7\u4ef6\u7684dockstyle\u5c5e\u6027\u5927\u4f53\u4e00\u81f4\u3002\u8bbe\u7f6e\u4e00\u4e2a\u9876\u90e8\u5e03\u5c40\u6216\u63a7\u4ef6\u4e3afill_parent\u5c06\u5f3a\u5236\u6027\u8ba9\u5b83\u5e03\u6ee1\u6574\u4e2a\u5c4f\u5e55\u3002<\/p>\n<p><strong>2\uff09 wrap_content<\/strong><\/p>\n<p>\u8bbe\u7f6e\u4e00\u4e2a\u89c6\u56fe\u7684\u5c3a\u5bf8\u4e3awrap_content\u5c06\u5f3a\u5236\u6027\u5730\u4f7f\u89c6\u56fe\u6269\u5c55\u4ee5\u663e\u793a\u5168\u90e8\u5185\u5bb9\u3002\u4ee5TextView\u548cImageView\u63a7\u4ef6\u4e3a\u4f8b\uff0c\u8bbe\u7f6e\u4e3awrap_content\u5c06\u5b8c\u6574\u663e\u793a\u5176\u5185\u90e8\u7684\u6587\u672c\u548c\u56fe\u50cf\u3002\u5e03\u5c40\u5143\u7d20\u5c06\u6839\u636e\u5185\u5bb9\u66f4\u6539\u5927\u5c0f\u3002\u8bbe\u7f6e\u4e00\u4e2a\u89c6\u56fe\u7684\u5c3a\u5bf8\u4e3awrap_content\u5927\u4f53\u7b49\u540c\u4e8e\u8bbe\u7f6eWindows\u63a7\u4ef6\u7684Autosize\u5c5e\u6027\u4e3aTrue\u3002<\/p>\n<p><strong>3\uff09match_parent<\/strong><br \/>\nAndroid2.2\u4e2dmatch_parent\u548cfill_parent\u662f\u4e00\u4e2a\u610f\u601d .\u4e24\u4e2a\u53c2\u6570\u610f\u601d\u4e00\u6837\uff0cmatch_parent\u66f4\u8d34\u5207\uff0c\u4e8e\u662f\u4ece2.2\u5f00\u59cb\u4e24\u4e2a\u8bcd\u90fd\u53ef\u4ee5\u7528\u3002\u90a3\u4e48\u5982\u679c\u8003\u8651\u4f4e\u7248\u672c\u7684\u4f7f\u7528\u60c5\u51b5\u4f60\u5c31\u9700\u8981\u7528fill_parent\u4e86<\/p>\n<h1>2 \u4e94\u79cd\u5e03\u5c40\u53ca\u5176\u91cd\u8981\u6807\u7b7e<\/h1>\n<ul>\n<li>\u00a0\u6846\u67b6\u5e03\u5c40<span style=\"font-family: 'Times New Roman', serif;\">FrameLayout<\/span>\u91cd\u8981\u6807\u7b7e\uff1a<\/li>\n<\/ul>\n<div>\n<p>android:layout_gravity<\/p>\n<p>\u53c2\u8003 \u00a0 \u00a0<a href=\"http:\/\/wenku.baidu.com\/view\/12ca5929b4daa58da0114aea.html\">http:\/\/wenku.baidu.com\/view\/12ca5929b4daa58da0114aea.html<\/a><\/p>\n<p>android:background<\/p>\n<p>android:layout_marginTop<\/p>\n<p>android:layout_marginBottom<\/p>\n<\/div>\n<div><\/div>\n<div><\/div>\n<ul>\n<li>\u00a0\u7ebf\u6027\u5e03\u5c40LinearLayout<\/li>\n<\/ul>\n<p><span style=\"font-family: 'Times New Roman', serif;\">\u00a0\u00a0<\/span><span style=\"font-family: 'Times New Roman', serif;\">android:orientation<\/span><\/p>\n<p>\u5b83\u786e\u5b9a\u4e86LinearLayout\u7684\u65b9\u5411\uff0c\u5176\u503c\u53ef\u4ee5\u4e3a<\/p>\n<p>*vertical\uff0c \u8868\u793a\u5782\u76f4\u5e03\u5c40<\/p>\n<p>*horizontal\uff0c \u8868\u793a\u6c34\u5e73\u5e03\u5c40<\/p>\n<p><span style=\"font-family: 'Times New Roman', serif;\">android:layout_gravity<\/span><\/p>\n<p>\u540c\u4e0a\u3002<\/p>\n<p><span style=\"font-family: 'Times New Roman', serif;\">android:layout_weight<\/span><\/p>\n<ul>\n<li>\u00a0\u6846\u67b6\u5e03\u5c40 FrameLayout<\/li>\n<\/ul>\n<p>\u5173\u4e8e\u8bbe\u7f6eandroid:layout_marginTop\u7b49\u5c5e\u6027\u5931\u6548<\/p>\n<p>\u6846\u67b6\u5e03\u5c40\u662f\u76f4\u63a5\u8986\u76d6\u5728\u539f\u56fe\u5c42\u4e0a\u7684\u3002\u5982\u679c\u8981\u5b9a\u4f4d\u6211\u4eec\u9700\u5148\u8bbe\u7f6e\u00a0\u00a0 \u00a0 android:layout_gravity=&#8221;left&#8221;<\/p>\n<p>\u7136\u540e\u518d\u8bbe\u7f6eandroid:layout_marginTop\u7b49\u5c5e\u6027 \u5426\u5219\u65e0\u6548<\/p>\n<ul>\n<li>\u76f8\u5bf9\u5e03\u5c40RelativeLayout<\/li>\n<\/ul>\n<p>\u76f8\u5bf9\u5e03\u5c40\u00a0RelativeLayout\u00a0\u5141\u8bb8\u5b50\u5143\u7d20\u6307\u5b9a\u5b83\u4eec\u76f8\u5bf9\u4e8e\u5176\u7236\u5143\u7d20\u6216\u5144\u5f1f\u5143\u7d20\u7684\u4f4d\u7f6e\uff0c\u8fd9\u662f\u5b9e\u9645\u5e03\u5c40\u4e2d\u6700\u5e38\u7528\u7684\u5e03\u5c40\u65b9\u5f0f\u4e4b\u4e00\u3002\u5b83\u7075\u6d3b\u6027\u5927\u5f88\u591a\uff0c\u5f53\u7136\u5c5e\u6027\u4e5f\u591a\uff0c\u64cd\u4f5c\u96be\u5ea6\u4e5f\u5927\uff0c\u5c5e\u6027\u4e4b\u95f4\u4ea7\u751f\u51b2\u7a81\u7684\u7684\u53ef\u80fd\u6027\u4e5f\u5927\uff0c\u4f7f\u7528\u76f8\u5bf9\u5e03\u5c40\u65f6\u8981\u591a\u505a\u4e9b\u6d4b\u8bd5\u3002<\/p>\n<p><a href=\"http:\/\/photo.blog.sina.com.cn\/showpic.html#blogid=40797b1001010vwt&amp;url=http:\/\/s9.sinaimg.cn\/orignal\/40797b10tc250df40dc58\" target=\"_blank\"><img decoding=\"async\" title=\"RelativeLayout\u76f8\u5bf9\u5e03\u5c40\" src=\"http:\/\/s9.sinaimg.cn\/middle\/40797b10tc250df40dc58&amp;690\" alt=\"RelativeLayout\u76f8\u5bf9\u5e03\u5c40\" name=\"image_operate_14681339552555190\" \/><\/a><\/p>\n<p><a href=\"http:\/\/photo.blog.sina.com.cn\/showpic.html#blogid=40797b1001010vwt&amp;url=http:\/\/s8.sinaimg.cn\/orignal\/40797b10tc250e1f2a0e7\" target=\"_blank\"><img decoding=\"async\" title=\"RelativeLayout\u76f8\u5bf9\u5e03\u5c40\" src=\"http:\/\/s8.sinaimg.cn\/middle\/40797b10tc250e1f2a0e7&amp;690\" alt=\"RelativeLayout\u76f8\u5bf9\u5e03\u5c40\" name=\"image_operate_90141339552612740\" \/><\/a><\/p>\n<p>\u4e0b\u9762\u662f\u5e38\u7528\u7684\u4e00\u4e9b\u5c5e\u6027<\/p>\n<p align=\"left\"><strong>RelativeLayout<\/strong>\u7528\u5230\u7684\u4e00\u4e9b\u91cd\u8981\u7684\u5c5e\u6027\uff1a<\/p>\n<p align=\"left\">\u7b2c\u4e00\u7c7b:\u5c5e\u6027\u503c\u4e3atrue\u6216false<br \/>\nandroid:layout_centerHrizontal \u6c34\u5e73\u5c45\u4e2d<br \/>\nandroid:layout_centerVertical \u5782\u76f4\u5c45\u4e2d<br \/>\nandroid:layout_centerInparent \u76f8\u5bf9\u4e8e\u7236\u5143\u7d20\u5b8c\u5168\u5c45\u4e2d<br \/>\nandroid:layout_alignParentBottom \u8d34\u7d27\u7236\u5143\u7d20\u7684\u4e0b\u8fb9\u7f18<br \/>\nandroid:layout_alignParentLeft \u8d34\u7d27\u7236\u5143\u7d20\u7684\u5de6\u8fb9\u7f18<br \/>\nandroid:layout_alignParentRight \u8d34\u7d27\u7236\u5143\u7d20\u7684\u53f3\u8fb9\u7f18<br \/>\nandroid:layout_alignParentTop \u8d34\u7d27\u7236\u5143\u7d20\u7684\u4e0a\u8fb9\u7f18<br \/>\nandroid:layout_alignWithParentIfMissing<wbr>\u00a0\u5982\u679c\u5bf9\u5e94\u7684\u5144\u5f1f\u5143\u7d20\u627e\u4e0d\u5230\u7684\u8bdd\u5c31\u4ee5\u7236\u5143\u7d20\u505a\u53c2\u7167\u7269<\/wbr><\/p>\n<p align=\"left\">\u7b2c\u4e8c\u7c7b\uff1a\u5c5e\u6027\u503c\u5fc5\u987b\u4e3aid\u7684\u5f15\u7528\u540d\u201c@id\/id-name\u201d<br \/>\nandroid:layout_below \u5728\u67d0\u5143\u7d20\u7684\u4e0b\u65b9<br \/>\nandroid:layout_above \u5728\u67d0\u5143\u7d20\u7684\u7684\u4e0a\u65b9<br \/>\nandroid:layout_toLeftOf \u5728\u67d0\u5143\u7d20\u7684\u5de6\u8fb9<br \/>\nandroid:layout_toRightOf \u5728\u67d0\u5143\u7d20\u7684\u53f3\u8fb9<\/p>\n<p align=\"left\">android:layout_alignTop \u672c\u5143\u7d20\u7684\u4e0a\u8fb9\u7f18\u548c\u67d0\u5143\u7d20\u7684\u7684\u4e0a\u8fb9\u7f18\u5bf9\u9f50<br \/>\nandroid:layout_alignLeft \u672c\u5143\u7d20\u7684\u5de6\u8fb9\u7f18\u548c\u67d0\u5143\u7d20\u7684\u7684\u5de6\u8fb9\u7f18\u5bf9\u9f50<br \/>\nandroid:layout_alignBottom \u672c\u5143\u7d20\u7684\u4e0b\u8fb9\u7f18\u548c\u67d0\u5143\u7d20\u7684\u7684\u4e0b\u8fb9\u7f18\u5bf9\u9f50<br \/>\nandroid:layout_alignRight \u672c\u5143\u7d20\u7684\u53f3\u8fb9\u7f18\u548c\u67d0\u5143\u7d20\u7684\u7684\u53f3\u8fb9\u7f18\u5bf9\u9f50<\/p>\n<p align=\"left\">\u7b2c\u4e09\u7c7b\uff1a\u5c5e\u6027\u503c\u4e3a\u5177\u4f53\u7684\u50cf\u7d20\u503c\uff0c\u598230dip\uff0c40px<br \/>\nandroid:layout_marginBottom \u79bb\u67d0\u5143\u7d20\u5e95\u8fb9\u7f18\u7684\u8ddd\u79bb<br \/>\nandroid:layout_marginLeft \u79bb\u67d0\u5143\u7d20\u5de6\u8fb9\u7f18\u7684\u8ddd\u79bb<br \/>\nandroid:layout_marginRight \u79bb\u67d0\u5143\u7d20\u53f3\u8fb9\u7f18\u7684\u8ddd\u79bb<br \/>\nandroid:layout_marginTop \u79bb\u67d0\u5143\u7d20\u4e0a\u8fb9\u7f18\u7684\u8ddd\u79bb<\/p>\n<p align=\"left\">\n<strong>EditText<\/strong><strong>\u7684<\/strong><strong>android:hint<\/strong><\/p>\n<p align=\"left\">\u8bbe\u7f6eEditText\u4e3a\u7a7a\u65f6\u8f93\u5165\u6846\u5185\u7684\u63d0\u793a\u4fe1\u606f\u3002<\/p>\n<p align=\"left\"><strong>android:gravity<\/strong><br \/>\nandroid:gravity\u5c5e\u6027\u662f\u5bf9\u8be5view \u5185\u5bb9\u7684\u9650\u5b9a\uff0e\u6bd4\u5982\u4e00\u4e2abutton \u4e0a\u9762\u7684text. \u4f60\u53ef\u4ee5\u8bbe\u7f6e\u8be5text \u5728view\u7684\u9760\u5de6\uff0c\u9760\u53f3\u7b49\u4f4d\u7f6e\uff0e\u4ee5button\u4e3a\u4f8b\uff0candroid:gravity=&#8221;right&#8221;\u5219button\u4e0a\u9762\u7684\u6587\u5b57\u9760\u53f3<\/p>\n<p align=\"left\"><strong>android:layout_gravity<\/strong><br \/>\nandroid:layout_gravity\u662f\u7528\u6765\u8bbe\u7f6e\u8be5view\u76f8\u5bf9\u4e0e\u8d77\u7236view \u7684\u4f4d\u7f6e\uff0e\u6bd4\u5982\u4e00\u4e2abutton \u5728linearlayout\u91cc\uff0c\u4f60\u60f3\u628a\u8be5button\u653e\u5728\u9760\u5de6\u3001\u9760\u53f3\u7b49\u4f4d\u7f6e\u5c31\u53ef\u4ee5\u901a\u8fc7\u8be5\u5c5e\u6027\u8bbe\u7f6e\uff0e\u4ee5button\u4e3a\u4f8b\uff0candroid:layout_gravity=&#8221;right&#8221;\u5219button\u9760\u53f3<br \/>\n<strong><br \/>\n<\/strong><strong>android:layout_alignParentRight<\/strong><br \/>\n\u4f7f\u5f53\u524d\u63a7\u4ef6\u7684\u53f3\u7aef\u548c\u7236\u63a7\u4ef6\u7684\u53f3\u7aef\u5bf9\u9f50\u3002\u8fd9\u91cc\u5c5e\u6027\u503c\u53ea\u80fd\u4e3atrue\u6216false\uff0c\u9ed8\u8ba4false\u3002<\/p>\n<p align=\"left\"><strong>android:scaleType<\/strong><strong>\uff1a<\/strong><br \/>\nandroid:scaleType\u662f\u63a7\u5236\u56fe\u7247\u5982\u4f55resized\/moved\u6765\u5339\u5bf9ImageView\u7684size\u3002ImageView.ScaleType \/ android:scaleType\u503c\u7684\u610f\u4e49\u533a\u522b\uff1a<\/p>\n<p align=\"left\">CENTER \/center \u6309\u56fe\u7247\u7684\u539f\u6765size\u5c45\u4e2d\u663e\u793a\uff0c\u5f53\u56fe\u7247\u957f\/\u5bbd\u8d85\u8fc7View\u7684\u957f\/\u5bbd\uff0c\u5219\u622a\u53d6\u56fe\u7247\u7684\u5c45\u4e2d\u90e8\u5206\u663e\u793a<\/p>\n<p align=\"left\">CENTER_CROP \/ centerCrop \u6309\u6bd4\u4f8b\u6269\u5927\u56fe\u7247\u7684size\u5c45\u4e2d\u663e\u793a\uff0c\u4f7f\u5f97\u56fe\u7247\u957f(\u5bbd)\u7b49\u4e8e\u6216\u5927\u4e8eView\u7684\u957f(\u5bbd)<\/p>\n<p align=\"left\">CENTER_INSIDE \/ centerInside \u5c06\u56fe\u7247\u7684\u5185\u5bb9\u5b8c\u6574\u5c45\u4e2d\u663e\u793a\uff0c\u901a\u8fc7\u6309\u6bd4\u4f8b\u7f29\u5c0f\u6216\u539f\u6765\u7684size\u4f7f\u5f97\u56fe\u7247\u957f\/\u5bbd\u7b49\u4e8e\u6216\u5c0f\u4e8eView\u7684\u957f\/\u5bbd<\/p>\n<p align=\"left\">FIT_CENTER \/ fitCenter \u628a\u56fe\u7247\u6309\u6bd4\u4f8b\u6269\u5927\/\u7f29\u5c0f\u5230View\u7684\u5bbd\u5ea6\uff0c\u5c45\u4e2d\u663e\u793a<\/p>\n<p align=\"left\">FIT_END \/ fitEnd \u628a\u56fe\u7247\u6309\u6bd4\u4f8b\u6269\u5927\/\u7f29\u5c0f\u5230View\u7684\u5bbd\u5ea6\uff0c\u663e\u793a\u5728View\u7684\u4e0b\u90e8\u5206\u4f4d\u7f6e<\/p>\n<p align=\"left\">FIT_START \/ fitStart \u628a\u56fe\u7247\u6309\u6bd4\u4f8b\u6269\u5927\/\u7f29\u5c0f\u5230View\u7684\u5bbd\u5ea6\uff0c\u663e\u793a\u5728View\u7684\u4e0a\u90e8\u5206\u4f4d\u7f6e<\/p>\n<p align=\"left\">FIT_XY \/ fitXY \u628a\u56fe\u7247\u4e0d\u6309\u6bd4\u4f8b\u6269\u5927\/\u7f29\u5c0f\u5230View\u7684\u5927\u5c0f\u663e\u793a<\/p>\n<p align=\"left\">MATRIX \/ matrix \u7528\u77e9\u9635\u6765\u7ed8\u5236\uff0c\u52a8\u6001\u7f29\u5c0f\u653e\u5927\u56fe\u7247\u6765\u663e\u793a\u3002<\/p>\n<p align=\"left\">** \u8981\u6ce8\u610f\u4e00\u70b9\uff0cDrawable\u6587\u4ef6\u5939\u91cc\u9762\u7684\u56fe\u7247\u547d\u540d\u662f\u4e0d\u80fd\u5927\u5199\u7684\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h1>\u5176\u4ed6<\/h1>\n<h2>Android\u4e2d\u7684Layout_weight\u8be6\u89e3<\/h2>\n<p><span style=\"color: red;\">\u5e03\u5c40\u6587\u4ef6\u662f\uff1a<\/span><\/p>\n<p><span style=\"font-family: Arial;\">&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<\/span><br \/>\n<span style=\"font-family: Arial;\">&lt;LinearLayout xmlns:android=&#8221;<\/span><span style=\"font-family: Arial;\">http:\/\/schemas.android.com\/apk\/res\/android<\/span><span style=\"font-family: Arial;\">&#8220;<\/span><br \/>\n<span style=\"font-family: Arial;\">\u00a0 \u00a0 android:orientation=&#8221;horizontal&#8221;<\/span><br \/>\n<span style=\"font-family: Arial;\">\u00a0 \u00a0 android:layout_width=&#8221;fill_parent&#8221;<\/span><br \/>\n<span style=\"font-family: Arial;\">\u00a0 \u00a0 android:layout_height=&#8221;fill_parent&#8221;<\/span><br \/>\n<span style=\"font-family: Arial;\">\u00a0 \u00a0 &gt;<\/span><br \/>\n<span style=\"font-family: Arial;\">&lt;Button<\/span><br \/>\n<span style=\"font-family: Arial;\"><span style=\"color: red;\">android:layout_width=&#8221;fill_parent&#8221;<\/span><\/span><br \/>\n<span style=\"font-family: Arial;\">android:layout_height=&#8221;wrap_content&#8221;<\/span><br \/>\n<span style=\"color: blue;\"><span style=\"font-family: Arial;\">android:layout_weight=&#8221;1&#8243;<\/span><\/span><br \/>\n<span style=\"font-family: Arial;\">android:text=&#8221;Button1&#8243;<\/span><br \/>\n<span style=\"font-family: Arial;\">\/&gt;<\/span><br \/>\n<span style=\"font-family: Arial;\">&lt;Button<\/span><br \/>\n<span style=\"font-family: Arial;\"><span style=\"color: red;\">android:layout_width=&#8221;fill_parent&#8221;<\/span><\/span><br \/>\n<span style=\"font-family: Arial;\">android:layout_height=&#8221;wrap_content&#8221;<\/span><br \/>\n<span style=\"color: blue;\"><span style=\"font-family: Arial;\">android:layout_weight=&#8221;2&#8243;<\/span><\/span><br \/>\n<span style=\"font-family: Arial;\">android:text=&#8221;Button2&#8243;<\/span><br \/>\n<span style=\"font-family: Arial;\">\/&gt;<\/span><br \/>\n<span style=\"font-family: Arial;\">&lt;\/LinearLayout&gt;<\/span><br \/>\n<span style=\"color: red;\">\u51fa\u73b0\u7684\u5e03\u5c40\u662f\uff1a<\/span>button1\u5360\u4e862\/3\uff0cbutton2\u5360\u4e861\/3\u3002<br \/>\n<img decoding=\"async\" id=\"aimg_35662\" title=\"57e34f80d09736ec6d811907.jpg.png\" src=\"http:\/\/www.eoeandroid.com\/data\/attachment\/forum\/201105\/20\/094023l2bs1o4n7y4gdsxl.png\" alt=\"57e34f80d09736ec6d811907.jpg.png\" width=\"320\" \/><br \/>\n\u4f46\u662f\u5982\u679c\u5c06\u5e03\u5c40\u6587\u4ef6\u4e2d\u7684button\u7684\u5c5e\u6027<span style=\"font-family: Arial;\"><span style=\"color: red;\">android:layout_width=&#8221;fill_parent&#8221;\u6539\u4e3a<\/span><\/span><span style=\"font-family: Arial;\"><span style=\"color: red;\">android:layout_width=&#8221;wrap_content&#8221;\u90a3\u4e48\u51fa\u73b0\u7684\u7ed3\u679c\u4e3a\uff1a<\/span><\/span>button1\u5360\u4e861\/3\uff0cbutton2\u5360\u4e862\/3\u3002<br \/>\n<span style=\"font-family: Arial;\"><span style=\"color: red;\"><img decoding=\"async\" id=\"aimg_35665\" title=\"3.png\" src=\"http:\/\/www.eoeandroid.com\/data\/attachment\/forum\/201105\/20\/094408c6mqf5551qjyjqjy.png\" alt=\"3.png\" width=\"320\" \/><\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<h1><\/h1>\n","protected":false},"excerpt":{"rendered":"<p>1.Android fill_parent\u3001wrap_content\u548cmatch_parent\u7684\u533a\u522b \u4e09\u4e2a\u5c5e\u6027\u90fd\u7528\u6765\u9002\u5e94\u89c6\u56fe\u7684\u6c34\u5e73\u6216\u5782\u76f4\u5927\u5c0f\uff0c\u4e00\u4e2a\u4ee5\u89c6\u56fe\u7684\u5185\u5bb9\u6216\u5c3a\u5bf8\u4e3a\u57fa\u7840\u7684\u5e03\u5c40\u6bd4\u7cbe\u786e\u5730\u6307\u5b9a\u89c6\u56fe\u8303\u56f4\u66f4\u52a0\u65b9\u4fbf\u3002 1\uff09fill_parent \u8bbe\u7f6e\u4e00\u4e2a\u6784\u4ef6\u7684\u5e03\u5c40\u4e3afill_parent\u5c06\u5f3a\u5236\u6027\u5730\u4f7f\u6784\u4ef6\u6269\u5c55\uff0c\u4ee5\u586b\u5145\u5e03\u5c40\u5355\u5143\u5185\u5c3d\u53ef\u80fd\u591a\u7684\u7a7a\u95f4\u3002\u8fd9\u8ddfWindows\u63a7\u4ef6\u7684dockstyle\u5c5e\u6027\u5927\u4f53\u4e00\u81f4\u3002\u8bbe\u7f6e\u4e00\u4e2a\u9876\u90e8\u5e03\u5c40\u6216\u63a7\u4ef6\u4e3afill_parent\u5c06\u5f3a\u5236\u6027\u8ba9\u5b83\u5e03\u6ee1\u6574\u4e2a\u5c4f\u5e55\u3002 2\uff09 wrap_content \u8bbe\u7f6e\u4e00\u4e2a\u89c6\u56fe\u7684\u5c3a\u5bf8\u4e3awrap_content\u5c06\u5f3a\u5236\u6027\u5730\u4f7f\u89c6\u56fe\u6269\u5c55\u4ee5\u663e\u793a\u5168\u90e8\u5185\u5bb9\u3002\u4ee5TextView\u548cImageView\u63a7\u4ef6\u4e3a\u4f8b\uff0c\u8bbe\u7f6e\u4e3awrap_content\u5c06\u5b8c\u6574\u663e\u793a\u5176\u5185\u90e8\u7684\u6587\u672c\u548c\u56fe\u50cf\u3002\u5e03\u5c40\u5143\u7d20\u5c06\u6839\u636e\u5185\u5bb9\u66f4\u6539\u5927\u5c0f\u3002\u8bbe\u7f6e\u4e00\u4e2a\u89c6\u56fe\u7684\u5c3a\u5bf8\u4e3awrap_content\u5927\u4f53\u7b49\u540c\u4e8e\u8bbe\u7f6eWindows\u63a7\u4ef6\u7684Autosize\u5c5e\u6027\u4e3aTrue\u3002 3\uff09match_parent Android2.2\u4e2dmatch_parent\u548cfill_parent\u662f\u4e00\u4e2a\u610f\u601d .\u4e24\u4e2a\u53c2\u6570\u610f\u601d\u4e00\u6837\uff0cmatch_parent\u66f4\u8d34\u5207\uff0c\u4e8e\u662f\u4ece2.2\u5f00\u59cb\u4e24\u4e2a\u8bcd\u90fd\u53ef\u4ee5\u7528\u3002\u90a3\u4e48\u5982\u679c\u8003\u8651\u4f4e\u7248\u672c\u7684\u4f7f\u7528\u60c5\u51b5\u4f60\u5c31\u9700\u8981\u7528fill_parent\u4e86 2 \u4e94\u79cd\u5e03\u5c40\u53ca\u5176\u91cd\u8981\u6807\u7b7e \u00a0\u6846\u67b6\u5e03\u5c40FrameLayout\u91cd\u8981\u6807\u7b7e\uff1a android:layout_gravity \u53c2\u8003 \u00a0 \u00a0http:\/\/wenku.baidu.com\/view\/12ca5929b4daa58da0114aea.html android:background android:layout_marginTop android:layout_marginBottom \u00a0\u7ebf\u6027\u5e03\u5c40LinearLayout \u00a0\u00a0android:orientation \u5b83\u786e\u5b9a\u4e86LinearLayout\u7684\u65b9\u5411\uff0c\u5176\u503c\u53ef\u4ee5\u4e3a *vertical\uff0c \u8868\u793a\u5782\u76f4\u5e03\u5c40 *horizontal\uff0c \u8868\u793a\u6c34\u5e73\u5e03\u5c40 android:layout_gravity \u540c\u4e0a\u3002 android:layout_weight \u00a0\u6846\u67b6\u5e03\u5c40 FrameLayout \u5173\u4e8e\u8bbe\u7f6eandroid:layout_marginTop\u7b49\u5c5e\u6027\u5931\u6548 \u6846\u67b6\u5e03\u5c40\u662f\u76f4\u63a5\u8986\u76d6\u5728\u539f\u56fe\u5c42\u4e0a\u7684\u3002\u5982\u679c\u8981\u5b9a\u4f4d\u6211\u4eec\u9700\u5148\u8bbe\u7f6e\u00a0\u00a0 \u00a0 android:layout_gravity=&#8221;left&#8221; \u7136\u540e\u518d\u8bbe\u7f6eandroid:layout_marginTop\u7b49\u5c5e\u6027 \u5426\u5219\u65e0\u6548 \u76f8\u5bf9\u5e03\u5c40RelativeLayout \u76f8\u5bf9\u5e03\u5c40\u00a0RelativeLayout\u00a0\u5141\u8bb8\u5b50\u5143\u7d20\u6307\u5b9a\u5b83\u4eec\u76f8\u5bf9\u4e8e\u5176\u7236\u5143\u7d20\u6216\u5144\u5f1f\u5143\u7d20\u7684\u4f4d\u7f6e\uff0c\u8fd9\u662f\u5b9e\u9645\u5e03\u5c40\u4e2d\u6700\u5e38\u7528\u7684\u5e03\u5c40\u65b9\u5f0f\u4e4b\u4e00\u3002\u5b83\u7075\u6d3b\u6027\u5927\u5f88\u591a\uff0c\u5f53\u7136\u5c5e\u6027\u4e5f\u591a\uff0c\u64cd\u4f5c\u96be\u5ea6\u4e5f\u5927\uff0c\u5c5e\u6027\u4e4b\u95f4\u4ea7\u751f\u51b2\u7a81\u7684\u7684\u53ef\u80fd\u6027\u4e5f\u5927\uff0c\u4f7f\u7528\u76f8\u5bf9\u5e03\u5c40\u65f6\u8981\u591a\u505a\u4e9b\u6d4b\u8bd5\u3002 \u4e0b\u9762\u662f\u5e38\u7528\u7684\u4e00\u4e9b\u5c5e\u6027 RelativeLayout\u7528\u5230\u7684\u4e00\u4e9b\u91cd\u8981\u7684\u5c5e\u6027\uff1a \u7b2c\u4e00\u7c7b:\u5c5e\u6027\u503c\u4e3atrue\u6216false android:layout_centerHrizontal \u6c34\u5e73\u5c45\u4e2d android:layout_centerVertical \u5782\u76f4\u5c45\u4e2d android:layout_centerInparent \u76f8\u5bf9\u4e8e\u7236\u5143\u7d20\u5b8c\u5168\u5c45\u4e2d android:layout_alignParentBottom \u8d34\u7d27\u7236\u5143\u7d20\u7684\u4e0b\u8fb9\u7f18 android:layout_alignParentLeft \u8d34\u7d27\u7236\u5143\u7d20\u7684\u5de6\u8fb9\u7f18 android:layout_alignParentRight &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.xiunian.wang\/?p=458\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;android UI\u5e03\u5c40\u5e38\u89c1\u95ee\u9898&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,8],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=\/wp\/v2\/posts\/458"}],"collection":[{"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=458"}],"version-history":[{"count":0,"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=\/wp\/v2\/posts\/458\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.xiunian.wang\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}