如何动态对齐控件? [英] How can I align controls in dynamicly?

查看:104
本文介绍了如何动态对齐控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,大家好;



我正在开发新软件以改善自己。但是我被困在某个地方。



我正在开发带字幕的视频播放器。所有字幕词都是控制。所有字幕单词都有mouseenter和mouseleave,这个控件是可点击的。



字幕需要在视频播放器屏幕中居中,但我不能这样做。



为了更好地理解,我添加图像。我希望,我解释一下我想做什么..



感谢您的回答...



http://tinypic.com/view.php?pic=33dzjv7&s=8# .VDMvQvl_vh4 [ ^ ]

Firstly hi everyone;

I'm develop new software for improve myself. But I'm stuck somewhere.

I'm developing video player with subtitle. All subtitle words are control. All subtitle words have mouseenter and mouseleave and this controls are clickable.

Subtitles need to be centered in the video player screen but I can't do it.

For better understanding, I'm add image. I hope, I explain what I want to do..

Thanks for all answer...

http://tinypic.com/view.php?pic=33dzjv7&s=8#.VDMvQvl_vh4[^]

推荐答案

我不明白你的意思。

但是,我猜你有一个字幕控件(例如,一个标签),并想把它(中心)对齐另一个控件(例如,一个面板)?你有标签的宽度和面板的宽度吗?只需做一点数学调整就可以调整标签的X位置并解决问题。



示例:

标签宽度为lW,面板宽度为pW

=>新标签的位置(X)=((lW + pW)/ 2) - lW

=>标签将放置在面板的中心
I don't get what you mean.
But, i guess you have a "subtitle" control (example, a label) and wanna align it (center) on another control (example, a panel) ? You have label's width and panel's width right ? Just do a little math to adjust label's X location and problem solved.

Example:
label's width is lW, panel's width is pW
=> new label's Location(X) = ((lW+pW)/2) - lW
=> label will placed at panel's center


这篇关于如何动态对齐控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆