你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

TouchGFX的button with label重新设置文字后,没有居中显示了

[复制链接]
lugl 提问时间:2025-10-25 20:23 / 未解决

我在动态设置按键文本后,显示文本是靠上显示。

image.png

按下后显示的效果:

image.png

代码如下:

void Screen1View::funstart()

{

// Override and implement this function in Screen1

// 获取bntRun的标签文本

touchgfx::TypedText btnRunText = butStrat.getLabelText();

// 判断按钮文本是否为"START"

if (touchgfx::Unicode::strncmp(btnRunText.getText(), TypedText(T_START).getText(), 8) == 0)

{

// 改变按钮文本为"STOP"

      runFlage = 1;

// MKS_RUN(0x8a);

      butStrat.setLabelText(touchgfx::TypedText(T_STOP));

      butStrat.invalidate();

}

else if (touchgfx::Unicode::strncmp(btnRunText.getText(), TypedText(T_STOP).getText(), 8) == 0)

{

    // 改变按钮文本为"START"

        runFlage = 0;

// MKS_RUN(0x88);

        butStrat.setLabelText(touchgfx::TypedText(T_START));

        butStrat.invalidate();

}

}

请问需要修改哪个属性才能剧中显示?

收藏 评论2 发布时间:2025-10-25 20:23

举报

2个回答
EPTmachine 回答时间:5 小时前

image.png

对应的Text的Alignment属性设置了吗?

lugl 回答时间:2 小时前

EPTmachine 发表于 2025-10-26 17:10
![image.png](data/attachment/forum/202510/26/170938zdu1onunosdm7dss.png?imageMogr2/auto-orient/s ...

[md]已经设置好了的。

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版