-
文本
方法:
Text()Text("默認") Text("大小、顏色", fontSize = 16.sp, color = Color.Blue) Text("斜體", fontStyle = FontStyle.Italic) Text("粗體", fontWeight = FontWeight.Bold) Text( "居中", textAlign = TextAlign.Center, modifier = Modifier.fillMaxWidth() ) Text("最大行數(shù) ".repeat(50), maxLines = 2) Text("文字溢出 ".repeat(50), maxLines = 2, overflow = TextOverflow.Ellipsis) Text("字體1", fontFamily = FontFamily.Serif) Text("字體2", fontFamily = FontFamily.SansSerif)文字可選擇:
SelectionContainer(){}文字不可選擇:
DisableSelection(){}可點擊文字:
ClickableText(){}組合文字:
buildAnnotatedString(){}Text( buildAnnotatedString { withStyle(style = SpanStyle(color = Color.Blue)) { append("H") } append("ello ") withStyle(style = SpanStyle(fontWeight = FontWeight.Bold, color = Color.Red)) { append("W") } append("orld") } ) -
圖片
方法:
Image()/Icon()。兩者沒太大區(qū)別Image(painterResource(R.drawable.xxx), "image") Icon(painterResource(R.drawable.xxx), "icon") -
縱向布局
Column使用
Column可將多個項垂直地放置在屏幕上Column { Text("1") Text("2") } -
橫向布局
Row
使用Row可將多個項水平地放置在屏幕上Row { Text("1") Text("2") } -
Box
使用Box可將一個元素放在另一個元素上Box { Box( Modifier .size(100.dp, 100.dp) .background(Color.Black) ) { } Box( Modifier .size(50.dp, 50.dp) .background(Color.Red) ) { } } -
列表
LazyColumnLazyColumn { // Add a single item item { Text(text = "First item") } // Add 5 items items(5) { index -> Text(text = "Item: $index") } // Add another single item item { Text(text = "Last item") } } -
橫向列表
LazyRowLazyRow(content = { item { Image(painterResource(R.drawable.xxx), "test") } item { Image(painterResource(R.drawable.xxx), "test") } })
Android Jetpack Compose控件基礎(chǔ)篇
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 導(dǎo)引 本文原文在這里:Flutter for Android developers本文屬于半翻譯半筆記注解,按照自...
- http://www.cnblogs.com/Sweet-Candy/p/5695389.html React-N...
- 對React-Native的學(xué)習(xí),從熟悉基本控件開始。 View 屬性方法 序號名稱屬性O(shè)r方法類型說明 1 ac...
- 1 IOS組件 1.1 iOS活動指示器 1.1.1 Props animatingbool型 顯示指示器(tru...