如何在 UiBinder XML 文件中使用 AbsolutePanel

发布于 2024-09-01 04:05:48 字数 98 浏览 3 评论 0原文

我想仅使用 ui.xml 文件来使用所述面板进行绝对布局,但不清楚这是否可能,因为文档集中于代码并完全忽略布局语言。我假设,由于教程没有提到这一点,所以这是不可能的,但我想确定一下。

I would like to do absolute layout using said panel by only using ui.xml file however it isn't clear if this is possible since the documentation concentrates on the code and ignores the layout language altogether. I'm assuming, since the tutorial doesn't mention this, it is impossible but would like to know for sure.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

要走干脆点 2024-09-08 04:05:48

我知道这已经很旧了,但他们更新了 AbsolutePanel 的 uibinder

在 UiBinder 模板中使用

UiBinder 中的 AbsolutePanel 元素
模板将他们的孩子布置成
绝对位置,使用
元素。每个 at 元素应该有
左侧和顶部属性(以像素为单位)。
它们还可以包含小部件子项
直接,不指定位置。

例如:

<g:AbsolutePanel>
   <g:at left='10' top='20'>
     <g:Label>Lorem ipsum...</g:Label>
   </g:at>
   <g:Label>...dolores est.</g:Label>
 </g:AbsolutePanel>

I know this is old, but they updated the uibinder for AbsolutePanel

Use in UiBinder Templates

AbsolutePanel elements in UiBinder
templates lay out their children with
absolute position, using
elements. Each at element should have
left and top attributes in pixels.
They also can contain widget children
directly, with no position specified.

For example:

<g:AbsolutePanel>
   <g:at left='10' top='20'>
     <g:Label>Lorem ipsum...</g:Label>
   </g:at>
   <g:Label>...dolores est.</g:Label>
 </g:AbsolutePanel>
有深☉意 2024-09-08 04:05:48

你是对的——目前没有办法做到这一点。这个问题可以在未来的 GWT 版本中通过引入一些自定义语法来解决,就像针对 DockLayoutPanel。但我对此表示怀疑 - 你想要编写这样的代码:

<g:AbsolutePanel ui:field="absolutePanel">
    <g:Button x="50px" y="50px">Test</g:Button>
</g:AbsolutePanel>

然而,这与“bean”冲突(如在 Java Beans 中;如果你有一个 getSomethingCool 方法,你可以编写 somethingCool ="kewl" 在 UiBinder 代码中,它将自动调用适当的 get/set 方法)样式 - 因为 Button 没有 setX/Y方法。这可以通过在编译时用对现有方法(CSS 定位等)的适当调用替换 setX/Y 调用来绕过。但这引入了另一种自定义行为,依赖于包装小部件/面板 - 我认为 GWT 开发人员希望避免这种情况。

You are right - there's no way to do this at the moment. This could be addressed in a future GWT release by introducing some custom syntax, like it was done for DockLayoutPanel. But I doubt it - you'd want to write code like this:

<g:AbsolutePanel ui:field="absolutePanel">
    <g:Button x="50px" y="50px">Test</g:Button>
</g:AbsolutePanel>

However this conflicts with the "bean" (as in Java Beans; if you have a getSomethingCool method, you can write somethingCool="kewl" in the UiBinder code and it will autmagically call the appropriate get/set method) style - because Button doesn't have a setX/Y method. This could be bypassed by replacing the setX/Y calls with appropriate calls to existing methods (CSS positioning, etc) at compile time. But this introduces yet another custom behavior, dependent on the wrapping Widget/Panel - I think the GWT devs would like to avoid that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文