GWT StackLayoutPanel:动态和自动高度 [英] GWT StackLayoutPanel: dynamic and automatic height

查看:211
本文介绍了GWT StackLayoutPanel:动态和自动高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用StackLayoutPanel来显示堆叠的电子邮件,其中头部是发件人,孩子是电子邮件正文。对于这种动态性质,我只能估计代码中堆栈的高度。为了估计身体的高度,我可以得到客户窗口的宽度,然后大概猜出身体占据的线数。但是这很费力,很可能是错误的。我的问题是:是否有一种方法让StackLayoutPanel与GWT API 2.2一样知道并自动设置当前显示的孩子显示的高度(加上它的头部和其他头部)?



恐怕不是这样,我试过其他的东西,失败。我试过了:


  1. 将StackLayoutPanel放在ScrollPanel中:


    • 如果我没有在代码中设置堆栈的大小,神秘的是我只能看到第一个堆栈的头文件,没有其他东西,不是它的主体,也没有其他头文件。



  2. 不在ScrollPanel里面

  3. 如果我确实设置了它,那么我就有估计身体高度的问题。 :
    堆栈会自动获取剩余窗口空间的大小,但这些页眉太多会相互重叠并相互叠加。

另外,StackLayoutPanel的默认行为似乎是在分配空间的最后显示其余的标题,而不仅仅是在before的标题的子元素之后。是否有可能改变这种情况?



有关这方面的帮助我们将非常感激。



//我知道类似的问题是这个,但我想我扩大它。

解决方案

你是对的,你扩展上一个问题答案很简单:stackLayoutPanel.setHeight((40 * numChildren + 200)+px);

200像素的尺寸取决于内容并且足够所以StackLayoutPanel可能不会为你削减它。



我认为你将要使用StackLayoutPanel的橱柜是使用一个固定的身体宽度,并使用ScrollPanel在身体内部(SP内部不是SLP)。通过这种方式,所有电子邮件都可以显示ScrollPanel中的所有内容。



由于这有点妥协,因此只需实现您自己的小部件。我可能会使用一个VerticalPanel作为基础的小部件,只是隐藏和显示div的(同时保持标题始终可见)

I'm using a StackLayoutPanel to show stacked emails of a conversation a la gmail where the header is the sender and the child the email's body. For the dynamic nature of this, I can only estimate the height of my stack in code. To estimate the body's height I could get the client's window's width then roughly guess how many lines the body occupies. But this is laborious and likely to be wrong.

My question is: is there a way for the StackLayoutPanel, as for GWT API 2.2, to know and so set automatically the height in display of the current shown child (plus its header and the other headers)?

I'm afraid not so I've tried other things that also, however, fail. I've tried:

  1. Put the StackLayoutPanel inside a ScrollPanel:

    • If I don't set in code a stack's size, mysteriously I can only see the first stack's header and nothing more, not its body, nor other headers.
    • If I do set it, then I have the problem of the body's height estimation.
  2. Not inside a ScrollPanel: the stack gets automatically the size of remaining window's space, but with too many headers these overlap and superimpose each other.

Also, it seems the default behaviour for StackLayoutPanel is to show the rest of headers at the very end of the allocated space, not just after the before's header's child. Is it possible to change this?

Help on this would be much appreciated.

//I know a similar question is this but I think I expand on it.

解决方案

You are right, you do expand on the previous question where the answer is a simple: stackLayoutPanel.setHeight((40*numChildren + 200)+"px");

The 200px body size is dependent on the content and enough so that StackLayoutPanel is probably not going to cut it for you.

I think the closet you are going to come with StackLayoutPanel is to use a fixed body width and use a ScrollPanel INSIDE the body (not SLP inside SP). This way all emails can show all content in ScrollPanel.

Since this is a bit of a compromise, the alternative is to just implement your own widget. I would probably use a VerticalPanel as the underlying widget and just hide and display div's (while keeping the headers visible all the time)

这篇关于GWT StackLayoutPanel:动态和自动高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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