#鸿蒙通关秘籍#如何设置应用局部页面自定义主题风格,并同时可配置子组件深浅色模式?

HarmonyOS
6天前
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
CodeNinja
啥都不说了,我直接上码:
@Entry
@Component
struct Index {
build() {
Column() {
Column() {
Text('无`WithTheme`')
.fontSize(40)
.fontWeight(FontWeight.Bold)
}
.justifyContent(FlexAlign.Center)
.width('100%')
.height('33%')
.backgroundColor($r('sys.color.background_primary'))

WithTheme({ colorMode: ThemeColorMode.DARK }) {
Column() {
Text('WithTheme')
.fontSize(40)
.fontWeight(FontWeight.Bold)
Text('DARK')
.fontSize(40)
.fontWeight(FontWeight.Bold)
}
.justifyContent(FlexAlign.Center)
.width('100%')
.height('33%')
.backgroundColor($r('sys.color.background_primary'))
}

WithTheme({ colorMode: ThemeColorMode.LIGHT }) {
Column() {
Text('WithTheme')
.fontSize(40)
.fontWeight(FontWeight.Bold)
Text('LIGHT')
.fontSize(40)
.fontWeight(FontWeight.Bold)
}
.justifyContent(FlexAlign.Center)
.width('100%')
.height('33%')
.backgroundColor($r('sys.color.background_primary'))
}
}
.height('100%')
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.END, SafeAreaEdge.BOTTOM, SafeAreaEdge.START])
}
}
分享
微博
QQ
微信
回复
6天前
相关问题
HarmonyOS 浅色深色主题如何设置
390浏览 • 1回复 待解决
HarmonyOS 应用名称如何自定义配置
135浏览 • 0回复 待解决
HarmonyOS 应用名称如何自定义配置
50浏览 • 1回复 待解决