初学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,转载请注明原文链接:https://www.cnblogs.com/yyh888/p/18260328