我是Echo 2框架的新手。我认为它应该很简单,但我发现无法水平和垂直居中生成的内容。 是否有可能获得具有固定宽度和高度的居中的ContentPane(或类似的东西)?

THX, 安德烈é

有帮助吗?

解决方案

找到echoPointNG的解决方案:

public static ContainerEx createCenteredPane( int width, int height ) {
    ContainerEx cp = new ContainerEx();
    cp.setPosition( Positionable.ABSOLUTE );
    cp.setOutsets( new Insets( width / 2 * -1, height / 2 * -1, 0, 0 ) );
    cp.setWidth( new Extent( width ) );
    cp.setHeight( new Extent( height ) );
    cp.setLeft( new Extent( 50, Extent.PERCENT ) );
    cp.setTop( new Extent( 50, Extent.PERCENT ) );
    return cp;
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top