Can anyone tell px:fp ratio or code to convert fp to px.
I am building a HarmonyOS application and I want to set the width of a component to 20fp but setWidth​(int width)
takes width in px.
Button button = new Button(getContext()); button.setWidth(width);
Advertisement
Answer
HarmonyOS provides the AttrHelper
tool class to implement conversion between fp and px.
AttrHelper.fp2px()
For more details, pls kindly refer to this Docs.