代码拉取完成,页面将自动刷新
同步操作将从 zlgopen/awtk 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
一般来说,我们希望设计的界面在不同分辨率的设备上都能正常显示,此时应该使用 layout 参数,而不要使用固定坐标和大小。
在有的情况下,设计时的分辨率与运行时的分辨率差不大,或者宽高之比的比例相近。比如手机,用 AWTK 开发的应用程序在手机上运行时,可以使用一种简便的方法,让 AWTK 自动调整子控件的坐标和大小(或者辅以 layout 参数进行微调)。
通过指定窗口下面这些属性,可以实现自动调整控件的坐标和大小。
/**
* @property {uint16_t} design_w
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* 设计时宽度。
*/
uint16_t design_w;
/**
* @property {uint16_t} design_h
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* 设计时高度。
*/
uint16_t design_h;
/**
* @property {bool_t} auto_scale_children_x
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* 窗口大小与设计时大小不同时,是否自动调整子控件的 x 坐标。
*/
uint16_t auto_scale_children_x : 1;
/**
* @property {bool_t} auto_scale_children_y
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* 窗口大小与设计时大小不同时,是否自动调整子控件的 y 坐标。
*/
uint16_t auto_scale_children_y : 1;
/**
* @property {bool_t} auto_scale_children_w
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* 窗口大小与设计时大小不同时,是否自动调整子控件的宽度。
*/
uint16_t auto_scale_children_w : 1;
/**
* @property {bool_t} auto_scale_children_h
* @annotation ["set_prop","get_prop","readable","persitent","design","scriptable"]
* 窗口大小与设计时大小不同时,是否自动调整子控件的高度。
*/
uint16_t auto_scale_children_h : 1;
如果子控件具有 self_layout 参数或者所在容器具有 children_layout 参数,则不使用自动调整功能。
示例:
<window
design_w="320" design_h="480"
auto_scale_children_x="true" auto_scale_children_y="true"
auto_scale_children_w="true" auto_scale_children_h="true" >
<button text="Hello" x="120" w="80" y="220" h="40" />
</window>
在代码中,可以使用下面这个函数自动调整控件的坐标和大小:
/**
* @method window_set_auto_scale_children
* 当设计分辨率和实际分辨率不一致时,自动调整子控件的位置和大小。
*
* > 当子控件有 self_layout 参数或者子控件的父控件有 children_layout 参数时,不会自动调整。
*
* @annotation ["scriptable"]
* @param {widget_t*} widget window 对象。
* @param {uint32_t} design_w 设计时宽度。
* @param {uint32_t} design_h 设计时高度。
*
* @return {ret_t} 返回 RET_OK 表示成功,否则表示失败。
*/
ret_t window_set_auto_scale_children(widget_t* widget, uint32_t design_w, uint32_t design_h);
示例:
widget_t* win = window_open("foobar");
window_set_auto_scale_children(win, 320, 480);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。