Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
谁能告诉px:fp比率或将 fp 转换为 px 的代码。 我正在构建一个 HarmonyOS 应用程序,我想将组件的宽度设置为 20fp,但setWidth(int width)宽度以 px 为单位。
setWidth(int width)
Button button = new Button(getContext()); button.setWidth(width);
HarmonyOS 提供了AttrHelper实现 fp 和 px 转换的工具类。
AttrHelper
AttrHelper.fp2px()
有关更多详细信息,请参阅此文档。