Skip to content
Advertisement

What is the alternative in Harmony OS for function setBackgroundColor() on View class in Android?

I am working on a HarmonyOS project in that I wanted to set the background color of the component. In Android we have a function setBackgroundColor() in the View class, this can be done as shown below.

JavaScript

How can I set background color to a component in HarmonyOS?

Advertisement

Answer

First you have to build an Element using some color,

JavaScript

later you have set the built element using setBackground API

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement