04. Compose字体

01. Compose 可组合组件之Row And Column

02. Compose 可组合组件之 属性 modifier

03. Compose 可组合组件之Card 图片

04. Compose字体

class FontActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        //创建字体
        val fontFamily = FontFamily(
            Font(R.font.opensans_bold, FontWeight.Bold),
            Font(R.font.opensans_light, FontWeight.Thin),
            Font(R.font.opensans_semibold, FontWeight.Normal),
        )

        setContent {
            Box(
                modifier = Modifier
                    .fillMaxSize()
                    .background(Color(0xFF101010))
            ) {
                Text(
//                    text = "Android Jetpack Compose",
                    text = buildAnnotatedString {
                        withStyle(
                            style = SpanStyle(
                                color = Color.Red,
                                fontSize = 24.sp
                            )
                        ) {
                            append("A")
                        }
                        append("ndroid ")
                        withStyle(
                            style = SpanStyle(
                                color = Color.Red,
                                fontSize = 24.sp
                            )
                        ) {
                            append("J")
                        }
                        append("etpack ")
                        withStyle(
                            style = SpanStyle(
                                color = Color.Red,
                                fontSize = 24.sp
                            )
                        ) {
                            append("C")
                        }
                        append("ompose")

                    },
                    color = Color.White,
                    fontSize = 20.sp,
                    fontFamily = fontFamily,
                    fontWeight = FontWeight.Bold,
//                    fontStyle = FontStyle.Italic,
                    textAlign = TextAlign.Center,
//                    textDecoration = TextDecoration.LineThrough,
//                    textDecoration = TextDecoration.Underline,
                )
            }
        }
    }
}
04. Compose字体
上一篇:[ATF]-TEE/REE系统切换时ATF的寄存器的保存和恢复


下一篇:SpringBoot实现上传下载(一)