谁能告诉px:fp将fp转换为px的比率或代码。
我正在构建一个HarmonyOS应用程序,我想将组件的宽度设置为20fp,但setWidth(int width)
的宽度为px。
Button button = new Button(getContext());
button.setWidth(width);
HarmonyOS提供AttrHelper
工具类来实现fp和px之间的转换。
AttrHelper.fp2px()
详情请参考本文档