初学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
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· 【.NET】调用本地 Deepseek 模型
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库