문제

나는 Echo 2 프레임 워크를 처음 사용합니다. 나는 그것이 단순해야한다고 생각하지만, 생성 된 컨텐츠를 가로 및 수직으로 중심으로하는 방법을 찾지 못했습니다. 고정 너비와 높이를 가진 중앙 콘텐츠 영역 (또는 유사한)을 얻을 가능성이 있습니까?

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