初學Android易混淆點
英文部分摘自Android官方課程
Modifier
Modifiers are used to decorate or add behavior to Jetpack Compose UI elements. For example, you can add backgrounds, padding or behavior to rows, text, or buttons. To set them, a composable or a layout needs to accept a modifier as a parameter.
The modifier argument ensures that the composables in the Column() function adhere to the constraints called on the modifier instance:
Column (modifier = modifier) { ... }
TextAlign
align the text to the center using textAlign
Alignment and Arrangement
這是我一開容易混淆的點,horizontalArrangement和verticalAlignment傻傻分不清。總結來說,
對于Row:使用horizontalArrangement and verticalAlignment,
對于Column:verticalArrangement and horizontalAlignment
下圖是使用效果
To set children's position within a Row, set the horizontalArrangement and verticalAlignment arguments. For a Column, set the verticalArrangement and horizontalAlignment arguments.
The arrangement property is used to arrange the child elements when the size of the layout is larger than the sum of its children.
For example: when the size of the Column is larger than the sum of its children sizes, a verticalArrangement can be specified to define the positioning of the children inside the Column. Below is an illustration of different vertical arrangements:

Similarly, when the size of the Row is larger than the sum of its children sizes, a horizontalArrangement can be specified to define the positioning of the children inside the Row. Below is an illustration of different horizontal arrangements:

ContentScale
You use the ContentScale.Crop parameter scaling, which scales the image uniformly to maintain the aspect ratio so that the width and height of the image are equal to, or larger than, the corresponding dimension of the screen.
本文來自博客園,作者:yyh888,轉載請注明原文鏈接:http://www.rzrgm.cn/yyh888/p/18260328

浙公網安備 33010602011771號