diff --git a/theme/GlobalThemeDemo/entry/src/main/ets/entryability/EntryAbility.ts b/theme/GlobalThemeDemo/entry/src/main/ets/entryability/EntryAbility.ts index d6f584f342abfeca213fb7c060eb28c3e93115f9..8cb37bf21271a64dce7aaab929e622937dff9708 100644 --- a/theme/GlobalThemeDemo/entry/src/main/ets/entryability/EntryAbility.ts +++ b/theme/GlobalThemeDemo/entry/src/main/ets/entryability/EntryAbility.ts @@ -3,15 +3,16 @@ import hilog from '@ohos.hilog'; import UIAbility from '@ohos.app.ability.UIAbility'; import Want from '@ohos.app.ability.Want'; import window from '@ohos.window'; +import { CustomColors, ThemeControl } from '@ohos.arkui.theme' -import { CustomColors } from '@ohos.arkui.styles' class RedColors implements CustomColors { fontEmphasize = 0xFFD53032 iconEmphasize = 0xFFD53032 backgroundEmphasize = 0xFFD53032 } const abilityThemeColors = new RedColors(); -ThemeControl.setDefaultTheme({colors: abilityThemeColors}) +// the invoking here does not have effect +// ThemeControl.setDefaultTheme({ colors: abilityThemeColors }) export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { @@ -32,6 +33,9 @@ export default class EntryAbility extends UIAbility { return; } hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + // invoking here works good + ThemeControl.setDefaultTheme({ colors: abilityThemeColors }) + hilog.info(0x0000, 'testTag', '%{public}s', 'ThemeControl.setDefaultTheme done'); }); }