{"id":45589,"date":"2021-11-11T22:19:17","date_gmt":"2021-11-11T13:19:17","guid":{"rendered":"https:\/\/www.charlezz.com\/?p=45589"},"modified":"2021-11-12T16:31:17","modified_gmt":"2021-11-12T07:31:17","slug":"layouts-in-jetpack-compose-%eb%a0%88%ec%9d%b4%ec%95%84%ec%9b%83-modifier%ec%97%90-%eb%8c%80%ed%95%b4-%ec%9e%90%ec%84%b8%ed%9e%88-%ec%95%8c%ec%95%84%eb%b3%b4%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/charlezz.com\/?p=45589","title":{"rendered":"Layouts In Jetpack Compose &#8211; \ub808\uc774\uc544\uc6c3 Modifier\uc5d0 \ub300\ud574 \uc790\uc138\ud788 \uc54c\uc544\ubcf4\uae30"},"content":{"rendered":"\n<p>modifier\uc758 \uae30\ubcf8\uc801\uc778 \ub0b4\uc6a9, \ucee4\uc2a4\ud140 \ucef4\ud3ec\uc800\ube14\uc744 \uc0dd\uc131\ud558\ub294 \ubc29\ubc95, \ud558\uc704\uc694\uc18c\ub4e4\uc744 \uc218\ub3d9\uc73c\ub85c \uce21\uc815\ud558\uace0 \ubc30\uce58\ud558\ub294 \ubc29\ubc95\uc5d0 \ub300\ud574\uc11c \uc54c\uc558\uc73c\ubbc0\ub85c modifier\uac00 \ub0b4\ubd80\uc5d0\uc11c \uc5b4\ub5bb\uac8c \uc791\ub3d9\ud558\ub294\uc9c0 \ub354 \uc798 \uc774\ud574\ud560 \uc218 \uc788\uc744 \uac83\uc774\ub2e4.<\/p>\n\n\n\n<p>\uc694\uc57d\ud558\uc790\uba74, <meta charset=\"utf-8\">modifier\ub4e4\uc740 \uc6b0\ub9ac\uac00 \ucef4\ud3ec\uc800\ube14\uc758 \ud589\ub3d9\uc744 \ucee4\uc2a4\ud140 \ud560 \uc218 \uc788\ub3c4\ub85d \ud55c\ub2e4. \ub2e4\uc591\ud55c <meta charset=\"utf-8\">modifier\ub4e4\uc744 \uccb4\uc774\ub2dd\ud558\uc5ec \ud568\uaed8 \uacb0\ud569\ud560 \uc218 \uc788\ub2e4. \uc5ec\ub7ec\uac00\uc9c0 \ud615\uc2dd\uc758 modifier\ub4e4\uc774 \uc788\uc9c0\ub9cc, \uc774\ubc88 \uc139\uc158\uc5d0\uc11c\ub294 UI \ucef4\ud3ec\ub10c\ud2b8\uac00 \uce21\uc815\ub418\uace0 \ubc30\uce58\ub418\ub294 \ubc29\uc2dd\uc744 \ubcc0\uacbd\ud560 \uc218 \uc788\uc73c\ubbc0\ub85c LayoutModifier\uc5d0 \ucd08\uc810\uc744 \ub9de\ucd9c \uac83\uc774\ub2e4.<\/p>\n\n\n\n<p>\ucef4\ud3ec\uc800\ube14\uc740 \uc790\uccb4 \ucf58\ud150\uce20\uc5d0 \ub300\ud55c \ucc45\uc784\uc774 \uc788\uc73c\uba70, \ud574\ub2f9 \ucef4\ud3ec\uc800\ube14\uc758 \uc791\uc131\uc790\uac00 \uba85\uc2dc\uc801\uc778 API\ub97c \ub178\ucd9c\ud558\uc9c0 \uc54a\ub294 \ud55c \uc0c1\uc704 \ucef4\ud3ec\uc800\ube14\uc774 \ud574\ub2f9 \ucf58\ud150\uce20\ub97c \uac80\uc0ac\ud558\uac70\ub098 \uc870\uc791\ud560 \uc218 \uc5c6\ub2e4. \uc720\uc0ac\ud558\uac8c, \ucef4\ud3ec\uc800\ube14\uc758 modifier\uc740 \uc218\uc815\ud558\ub294 \ub0b4\uc6a9\uc744 \ub178\ucd9c\uc2dc\ud0a4\uc9c0 \uc54a\uace0 \uc791\uc5c5\uc744 \uc218\ud589\ud55c\ub2e4. \uc989, modifier\ub4e4\uc740 \ucea1\uc290\ud654 \ub418\uc5b4\uc788\ub2e4.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Modifier\uc758 \ubd84\uc11d\ud558\uae30<\/h2>\n\n\n\n<p>Modifier \ubc0f LayoutModifier\ub294 public interface \uc774\uae30 \ub54c\ubb38\uc5d0, \uc790\uc2e0\ub9cc\uc758 Modifier\ub97c \uc0dd\uc131\ud560 \uc218 \uc788\ub2e4. \uc774\uc804\uc5d0 Modifier.padding\uc744 \uc0ac\uc6a9\ud588\ub358 \uac83\ucc98\ub7fc, Modifier\ub97c \uc880 \ub354 \uc790\uc138\ud788 \uc774\ud574\ud558\uae30 \uc704\ud574 \uad6c\ud604\ub0b4\uc6a9\uc744 \ubd84\uc11d\ud574\ubcf4\uae30\ub85c \ud558\uc790.<\/p>\n\n\n\n<p>padding\uc740 LayoutModifier \uc778\ud130\ud398\uc774\uc2a4\ub97c \uad6c\ud604\ud558\ub294 \ud074\ub798\uc2a4\uc5d0 \uc758\ud574 \uc9c0\uc6d0\ub418\ub294 \ud568\uc218\uc774\uba70, measure \uba54\uc11c\ub4dc\ub97c \uc7ac\uc815\uc758 \ud55c\ub2e4. PaddingModifier\ub294 \uc77c\ubc18\uc801\uc778 \ud074\ub798\uc2a4\ub85c equals()\ub97c \uad6c\ud604\ud558\uc5ec modifier\uac00 recomposition\uc2dc\uc5d0 \ube44\uad50 \ub420 \uc218 \uc788\ub3c4\ub85d \ud55c\ub2e4.<\/p>\n\n\n\n<p>\uc5ec\uae30 \uc544\ub798\uc758 \uc608\uc81c\ub97c \ubcf4\uba74, padding\uc774 \uc694\uc18c\uc758 \ud06c\uae30\uc640 \uc81c\uc57d\uc870\uac74\uc744 \uc218\uc815\ud558\ub294 \ubc29\ubc95\uc744 \uc54c \uc218 \uc788\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ modifier\ub97c \uc0dd\uc131\ud558\ub294 \ubc29\ubc95\n@Stable\nfun Modifier.padding(all: Dp) =\n\u00a0 \u00a0 this.then(\n\u00a0 \u00a0 \u00a0 \u00a0 PaddingModifier(start = all, top = all, end = all, bottom = all, rtlAware = true)\n\u00a0 \u00a0 )\n\n\/\/ \uc138\ubd80\ub0b4\uc6a9 \uad6c\ud604\nprivate class PaddingModifier(\n\u00a0 \u00a0 val start: Dp = 0.dp,\n\u00a0 \u00a0 val top: Dp = 0.dp,\n\u00a0 \u00a0 val end: Dp = 0.dp,\n\u00a0 \u00a0 val bottom: Dp = 0.dp,\n\u00a0 \u00a0 val rtlAware: Boolean,\n) : LayoutModifier {\n\n\u00a0 \u00a0 override fun MeasureScope.measure(\n\u00a0 \u00a0 \u00a0 \u00a0 measurable: Measurable,\n\u00a0 \u00a0 \u00a0 \u00a0 constraints: Constraints\n\u00a0 \u00a0 ): MeasureResult {\n\n\u00a0 \u00a0 \u00a0 \u00a0 val horizontal = start.roundToPx() + end.roundToPx()\n\u00a0 \u00a0 \u00a0 \u00a0 val vertical = top.roundToPx() + bottom.roundToPx()\n\n\u00a0 \u00a0 \u00a0 \u00a0 val placeable = measurable.measure(constraints.offset(-horizontal, -vertical))\n\n\u00a0 \u00a0 \u00a0 \u00a0 val width = constraints.constrainWidth(placeable.width + horizontal)\n\u00a0 \u00a0 \u00a0 \u00a0 val height = constraints.constrainHeight(placeable.height + vertical)\n\u00a0 \u00a0 \u00a0 \u00a0 return layout(width, height) {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 if (rtlAware) {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 placeable.placeRelative(start.roundToPx(), top.roundToPx())\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 } else {\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 placeable.place(start.roundToPx(), top.roundToPx())\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 \u00a0 \u00a0 }\n\u00a0 \u00a0 }\n}<\/code><\/pre>\n\n\n\n<p>\uc694\uc18c\uc758 \uc0c8\ub85c\uc6b4 \ub108\ube44\ub294 \ud558\uc704 \uc694\uc18c\uc758 \ub108\ube44\uac00 \ub418\uace0, \uc2dc\uc791 \ubc0f \ub05d padding \uac12\uc740 \uc694\uc18c\uc758 \ub108\ube44 \uc81c\uc57d\uc870\uac74\uc73c\ub85c \uac15\uc81c \ubcc0\ud658\ub41c\ub2e4.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\uc21c\uc11c\uc758 \uc911\uc694\uc131<\/h2>\n\n\n\n<p>\uccab\ubc88\uc9f8 \uc139\uc158\uc5d0\uc11c \ubd24\ub4ef\uc774, <strong>Modifier\ub97c \uccb4\uc774\ub2dd\ud560 \ub54c\ub294 \uc21c\uc11c\uac00 \uc911\uc694\ud558\ub2e4<\/strong>. modifier\ub4e4\uc740 \uba3c\uc800 \ud638\ucd9c\ub41c \uac83\ubd80\ud130\ud574\uc11c \ub098\uc911\uc5d0 \ud638\ucd9c\ub41c \uac83 \uc21c\uc73c\ub85c \ucef4\ud3ec\uc800\ube14\uc5d0 \uc801\uc6a9\ub418\ubbc0\ub85c, \uba3c\uc800 \ud638\ucd9c\ub41c modifier\uc758 \uce21\uc815 \ubc0f \uc804\uac1c \ub0b4\uc6a9\uc774 \ub2e4\uc74c\uc5d0 \uc624\ub294 modifier\uc5d0 \uc601\ud5a5\uc744 \ubbf8\uce5c\ub2e4. \ucef4\ud3ec\uc800\ube14\uc758 \ucd5c\uc885 \uc0ac\uc774\uc988\ub294 \ub9e4\uac1c\ubcc0\uc218\ub85c \uc804\ub2ec\ub41c \ubaa8\ub4e0 modifier\ub4e4\uc5d0 \uc758\uc874\ud55c\ub2e4.<\/p>\n\n\n\n<p>\uba3c\uc800, modifier\ub4e4\uc740 \uc67c\ucabd\uc5d0\uc11c \uc624\ub978\ucabd\uc73c\ub85c \uc81c\uc57d\uc870\uac74\ub4e4\uc744 \uac31\uc2e0\ud55c\ub2e4. \uadf8\ub7f0 \ub4a4, \ub2e4\uc2dc \uc624\ub978\ucabd\uc5d0\uc11c \uc67c\ucabd\uc73c\ub85c \uc0ac\uc774\uc988\ub97c \ubc18\ud658\ud55c\ub2e4. \ubc31\ubb38\uc774 \ubd88\uc5ec\uc77c\uacac \uc544\ub798\uc758 \uc608\uc81c\ub97c \ud655\uc778\ud558\ub3c4\ub85d \ud558\uc790.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Composable<br>fun BodyContent(modifier: Modifier = Modifier) {<br>&nbsp; &nbsp; Row(<br>&nbsp; &nbsp; &nbsp; &nbsp; modifier = modifier<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .background(color = Color.LightGray)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .size(200.dp)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .padding(16.dp)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .horizontalScroll(rememberScrollState())<br>&nbsp; &nbsp; ) {<br>&nbsp; &nbsp; &nbsp; &nbsp; StaggeredGrid {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (topic in topics) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Chip(modifier = Modifier.padding(8.dp), text = topic)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<p>\uc774 \ubc29\ubc95\uc73c\ub85c modifier\ub4e4\uc774 \uc801\uc6a9\ub41c \ubaa8\uc2b5\uc740 \ub2e4\uc74c\uacfc \uac19\uc740 \uacb0\uacfc\ub97c \ub0b3\ub294\ub2e4.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.charlezz.com\/wordpress\/wp-content\/uploads\/2021\/11\/www.charlezz.com-layouts-in-jetpack-compose-modifier-cb209bb5edf634d6-1024x659.png\" alt=\"\" class=\"wp-image-45590\" width=\"512\" height=\"330\" srcset=\"https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/11\/www.charlezz.com-layouts-in-jetpack-compose-modifier-cb209bb5edf634d6-1024x659.png 1024w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/11\/www.charlezz.com-layouts-in-jetpack-compose-modifier-cb209bb5edf634d6-300x193.png 300w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/11\/www.charlezz.com-layouts-in-jetpack-compose-modifier-cb209bb5edf634d6-768x494.png 768w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/11\/www.charlezz.com-layouts-in-jetpack-compose-modifier-cb209bb5edf634d6.png 1076w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<p>\uba3c\uc800, \ubc30\uacbd\uc744 \ubcc0\uacbd\ud558\uc5ec \uc5b4\ub5bb\uac8c UI\uc5d0 modifier\ub4e4\uc774 \uc601\ud5a5\uc744 \uc8fc\ub294\uc9c0 \ubcf8\ub2e4. \uadf8\ub7f0 \ub4a4\uc5d0 \ub108\ube44 \ubc0f \ub192\uc774\uc758 \uc0ac\uc774\uc988\ub97c 200dp\ub85c \uc81c\ud55c\ud55c\ub2e4. \uadf8\ub9ac\uace0 \ub9c8\uc9c0\ub9c9\uc73c\ub85c \ud14d\uc2a4\ud2b8\uc640 \uc8fc\ubcc0\ubd80\uc5d0 \uc5ec\ubc31\uc744 \ucd94\uac00\ud558\ub294 padding\uc744 \uc801\uc6a9\ud55c\ub2e4.<\/p>\n\n\n\n<p>\uc67c\ucabd\uc5d0\uc11c \uc624\ub978\ucabd\uc73c\ub85c \uc81c\uc57d\uc870\uac74\uc774 \uc804\ud30c\ub418\uae30 \ub54c\ubb38\uc5d0, \uce21\uc815\ub418\uc5b4\uc9c0\ub294 Row\uc5d0 \uc788\ub294 \ub0b4\uc6a9\uacfc \ud568\uaed8 \uc81c\uc57d\uc870\uac74\uc740 \ub108\ube44 \ubc0f \ub192\uc774\uc5d0 \ub300\ud55c \ucd5c\uc18c, \ucd5c\ub300\uce58\uc5d0 \ub300\ud574 \uac00\ub85c\ub108\ube44 200dp\uc5d0\uc11c \uc591\ucabd\uc5d0 padding \ube7c\uc57c\ud558\ubbc0\ub85c 168dp(=200dp-16dp-16dp)\uac00 \ub41c\ub2e4. \uc774\uac83\uc774 \uc758\ubbf8\ud558\ub294 \uc810\uc740 StaggeredGrid\uc758 \uc0ac\uc774\uc988\uac00 \uc815\ud655\ud558\uac8c 168x168dp\uac00 \ub41c\ub2e4\ub294 \uac83\uc774\ub2e4. \uadf8\ub7ec\ubbc0\ub85c, \uc0ac\uc774\uc988\ub97c \uc218\uc815\ud558\ub294 \uccb4\uc774\ub2dd\uc774 \uc624\ub978\ucabd\uc5d0\uc11c \uc67c\ucabd\uc73c\ub85c \uc2e4\ud589 \ub41c \ud6c4 \uc2a4\ud06c\ub864 \uac00\ub2a5\ud55c Row\uc758 \ucd5c\uc885 \uc0ac\uc774\uc988\ub294 200x200dp\uac00 \ub41c\ub2e4.<\/p>\n\n\n\n<p>\ub9cc\uc57d \uba3c\uc800 padding\uc744 \uc801\uc6a9\ud558\uace0 \uc0ac\uc774\uc988\ub97c \uc801\uc6a9\ud558\uae30 \uc704\ud574 modifier\ub4e4\uc758 \uc21c\uc11c\ub97c \ubcc0\uacbd\ud55c\ub2e4\uba74, \ub2e4\ub978 UI\ub97c \uac16\uac8c \ub41c\ub2e4.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Composable<br>fun BodyContent(modifier: Modifier = Modifier) {<br>&nbsp; &nbsp; Row(<br>&nbsp; &nbsp; &nbsp; &nbsp; modifier = modifier<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .background(color = Color.LightGray, shape = RectangleShape)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .padding(16.dp)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .size(200.dp)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .horizontalScroll(rememberScrollState())<br>&nbsp; &nbsp; ) {<br>&nbsp; &nbsp; &nbsp; &nbsp; StaggeredGrid {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (topic in topics) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Chip(modifier = Modifier.padding(8.dp), text = topic)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n\n\n\n<p>\ubbf8\ub9ac\ubcf4\uae30\ub85c \ubcf4\uba74 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.charlezz.com\/wordpress\/wp-content\/uploads\/2021\/11\/www.charlezz.com-layouts-in-jetpack-compose-modifier-17da5805d6d8fc91-1024x758.png\" alt=\"\" class=\"wp-image-45591\" width=\"512\" height=\"379\" srcset=\"https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/11\/www.charlezz.com-layouts-in-jetpack-compose-modifier-17da5805d6d8fc91-1024x758.png 1024w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/11\/www.charlezz.com-layouts-in-jetpack-compose-modifier-17da5805d6d8fc91-300x222.png 300w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/11\/www.charlezz.com-layouts-in-jetpack-compose-modifier-17da5805d6d8fc91-768x568.png 768w, https:\/\/charlezz.com\/wordpress\/wp-content\/uploads\/2021\/11\/www.charlezz.com-layouts-in-jetpack-compose-modifier-17da5805d6d8fc91.png 1184w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<p>\uc774 \uacbd\uc6b0, \uc2a4\ud06c\ub864 \uac00\ub2a5\ud55c Row \ubc0f padding\uc744 \uc6d0\ub798 \uac00\uc9c0\uace0 \uc788\ub358 \uc81c\uc57d\uc870\uac74\ub4e4\uc740 \ud558\uc704 \uc694\uc18c\ub4e4\uc744 \uce21\uc815\ud558\uae30 \uc704\ud574 size \uc81c\uc57d\uc870\uac74\uc73c\ub85c \uac15\uc81c \ubcc0\ud658\ub41c\ub2e4. \uadf8\ub7ec\ubbc0\ub85c StaggeredGrid\ub294 \ucd5c\uc18c \ubc0f \ucd5c\ub300\uc5d0 \ub300\ud55c \ub108\ube44 \ubc0f \ub192\uc774 \ub458\ub2e4 200dp\ub85c \uc81c\ud55c\ub41c\ub2e4. StaggeredGrid \uc0ac\uc774\uc988\ub294 200&#215;200 dp\uc774\uace0 \uc0ac\uc774\uc988\uac00 \uc624\ub978\ucabd\uc5d0\uc11c \uc67c\ucabd\uc73c\ub85c \uc218\uc815\ub428\uc5d0 \ub530\ub77c, padding modifier\ub294 Row\uc758 \uc0ac\uc774\uc988\ub97c \uc99d\uac00\uc2dc\ucf1c (200+16+16) x (200+16+16) = 232&#215;232 \uac00 \ub41c\ub2e4. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\uc774 \uc139\uc158\uc5d0 \ub300\ud55c \uc804\uccb4 \ucf54\ub4dc<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>val topics = listOf(<br>&nbsp; &nbsp; \"Arts &amp; Crafts\", \"Beauty\", \"Books\", \"Business\", \"Comics\", \"Culinary\",<br>&nbsp; &nbsp; \"Design\", \"Fashion\", \"Film\", \"History\", \"Maths\", \"Music\", \"People\", \"Philosophy\",<br>&nbsp; &nbsp; \"Religion\", \"Social sciences\", \"Technology\", \"TV\", \"Writing\"<br>)<br><br>@Composable<br>fun LayoutsCodelab() {<br>&nbsp; &nbsp; Scaffold(<br>&nbsp; &nbsp; &nbsp; &nbsp; topBar = {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TopAppBar(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title = {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Text(text = \"LayoutsCodelab\")<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; },<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actions = {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; IconButton(onClick = { \/* doSomething() *\/ }) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Icon(Icons.Filled.Favorite, contentDescription = null)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; )<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; ) { innerPadding -&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; BodyContent(Modifier.padding(innerPadding))<br>&nbsp; &nbsp; }<br>}<br><br>@Composable<br>fun BodyContent(modifier: Modifier = Modifier) {<br>&nbsp; &nbsp; Row(modifier = modifier<br>&nbsp; &nbsp; &nbsp; &nbsp; .background(color = Color.LightGray)<br>&nbsp; &nbsp; &nbsp; &nbsp; .padding(16.dp)<br>&nbsp; &nbsp; &nbsp; &nbsp; .size(200.dp)<br>&nbsp; &nbsp; &nbsp; &nbsp; .horizontalScroll(rememberScrollState()),<br>&nbsp; &nbsp; &nbsp; &nbsp; content = {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StaggeredGrid {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (topic in topics) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Chip(modifier = Modifier.padding(8.dp), text = topic)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; })<br>}<br><br>@Composable<br>fun StaggeredGrid(<br>&nbsp; &nbsp; modifier: Modifier = Modifier,<br>&nbsp; &nbsp; rows: Int = 3,<br>&nbsp; &nbsp; content: @Composable () -&gt; Unit<br>) {<br>&nbsp; &nbsp; Layout(<br>&nbsp; &nbsp; &nbsp; &nbsp; modifier = modifier,<br>&nbsp; &nbsp; &nbsp; &nbsp; content = content<br>&nbsp; &nbsp; ) { measurables, constraints -&gt;<br><br>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ Keep track of the width of each row<br>&nbsp; &nbsp; &nbsp; &nbsp; val rowWidths = IntArray(rows) { 0 }<br><br>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ Keep track of the max height of each row<br>&nbsp; &nbsp; &nbsp; &nbsp; val rowHeights = IntArray(rows) { 0 }<br><br>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ Don't constrain child views further, measure them with given constraints<br>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ List of measured children<br>&nbsp; &nbsp; &nbsp; &nbsp; val placeables = measurables.mapIndexed { index, measurable -&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ Measure each child<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; val placeable = measurable.measure(constraints)<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ Track the width and max height of each row<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; val row = index % rows<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowWidths&#91;row] += placeable.width<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowHeights&#91;row] = Math.max(rowHeights&#91;row], placeable.height)<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; placeable<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br><br>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ Grid's width is the widest row<br>&nbsp; &nbsp; &nbsp; &nbsp; val width = rowWidths.maxOrNull()<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ?.coerceIn(constraints.minWidth.rangeTo(constraints.maxWidth)) ?: constraints.minWidth<br><br>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ Grid's height is the sum of the tallest element of each row<br>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ coerced to the height constraints<br>&nbsp; &nbsp; &nbsp; &nbsp; val height = rowHeights.sumOf { it }<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .coerceIn(constraints.minHeight.rangeTo(constraints.maxHeight))<br><br>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ Y of each row, based on the height accumulation of previous rows<br>&nbsp; &nbsp; &nbsp; &nbsp; val rowY = IntArray(rows) { 0 }<br>&nbsp; &nbsp; &nbsp; &nbsp; for (i in 1 until rows) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowY&#91;i] = rowY&#91;i - 1] + rowHeights&#91;i - 1]<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br><br>&nbsp; &nbsp; &nbsp; &nbsp; \/\/ Set the size of the parent layout<br>&nbsp; &nbsp; &nbsp; &nbsp; layout(width, height) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \/\/ x co-ord we have placed up to, per row<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; val rowX = IntArray(rows) { 0 }<br><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; placeables.forEachIndexed { index, placeable -&gt;<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; val row = index % rows<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; placeable.placeRelative(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = rowX&#91;row],<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y = rowY&#91;row]<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; )<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowX&#91;row] += placeable.width<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>}<br><br>@Composable<br>fun Chip(modifier: Modifier = Modifier, text: String) {<br>&nbsp; &nbsp; Card(<br>&nbsp; &nbsp; &nbsp; &nbsp; modifier = modifier,<br>&nbsp; &nbsp; &nbsp; &nbsp; border = BorderStroke(color = Color.Black, width = Dp.Hairline),<br>&nbsp; &nbsp; &nbsp; &nbsp; shape = RoundedCornerShape(8.dp)<br>&nbsp; &nbsp; ) {<br>&nbsp; &nbsp; &nbsp; &nbsp; Row(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; modifier = Modifier.padding(start = 8.dp, top = 4.dp, end = 8.dp, bottom = 4.dp),<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; verticalAlignment = Alignment.CenterVertically<br>&nbsp; &nbsp; &nbsp; &nbsp; ) {<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Box(<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; modifier = Modifier<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .size(16.dp, 16.dp)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .background(color = MaterialTheme.colors.secondary)<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; )<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Spacer(Modifier.width(4.dp))<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Text(text = text)<br>&nbsp; &nbsp; &nbsp; &nbsp; }<br>&nbsp; &nbsp; }<br>}<br><br>@Preview<br>@Composable<br>fun ChipPreview() {<br>&nbsp; &nbsp; LayoutsCodelabTheme {<br>&nbsp; &nbsp; &nbsp; &nbsp; Chip(text = \"Hi there\")<br>&nbsp; &nbsp; }<br>}<br><br>@Preview<br>@Composable<br>fun LayoutsCodelabPreview() {<br>&nbsp; &nbsp; LayoutsCodelabTheme {<br>&nbsp; &nbsp; &nbsp; &nbsp; LayoutsCodelab()<br>&nbsp; &nbsp; }<br>}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>modifier\uc758 \uae30\ubcf8\uc801\uc778 \ub0b4\uc6a9, \ucee4\uc2a4\ud140 \ucef4\ud3ec\uc800\ube14\uc744 \uc0dd\uc131\ud558\ub294 \ubc29\ubc95, \ud558\uc704\uc694\uc18c\ub4e4\uc744 \uc218\ub3d9\uc73c\ub85c \uce21\uc815\ud558\uace0 \ubc30\uce58\ud558\ub294 \ubc29\ubc95\uc5d0 \ub300\ud574\uc11c \uc54c\uc558\uc73c\ubbc0\ub85c modifier\uac00 \ub0b4\ubd80\uc5d0\uc11c \uc5b4\ub5bb\uac8c \uc791\ub3d9\ud558\ub294\uc9c0 \ub354 \uc798 \uc774\ud574\ud560 \uc218 \uc788\uc744 \uac83\uc774\ub2e4. \uc694\uc57d\ud558\uc790\uba74, modifier\ub4e4\uc740 \uc6b0\ub9ac\uac00 \ucef4\ud3ec\uc800\ube14\uc758 \ud589\ub3d9\uc744 \ucee4\uc2a4\ud140 \ud560 \uc218 \uc788\ub3c4\ub85d \ud55c\ub2e4. \ub2e4\uc591\ud55c modifier\ub4e4\uc744 \uccb4\uc774\ub2dd\ud558\uc5ec \ud568\uaed8 \uacb0\ud569\ud560 \uc218 \uc788\ub2e4. \uc5ec\ub7ec\uac00\uc9c0 \ud615\uc2dd\uc758 modifier\ub4e4\uc774 \uc788\uc9c0\ub9cc, \uc774\ubc88 \uc139\uc158\uc5d0\uc11c\ub294 UI \ucef4\ud3ec\ub10c\ud2b8\uac00 \uce21\uc815\ub418\uace0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[38],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45589"}],"collection":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=45589"}],"version-history":[{"count":1,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45589\/revisions"}],"predecessor-version":[{"id":45592,"href":"https:\/\/charlezz.com\/index.php?rest_route=\/wp\/v2\/posts\/45589\/revisions\/45592"}],"wp:attachment":[{"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=45589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=45589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/charlezz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=45589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}