public class Viewport extends SimpleContainer
A LayoutContainer that fills the browser window and monitors window resizing. Viewports are best used for applications that will fill the browser without window scrolling. Children of the viewport can allow scrolling.
public void onModuleLoad() {
Viewport viewport = new Viewport();
viewport.setWidget(new ContentPanel(), new MarginData(10));
RootPanel.get().add(viewport);
}
The viewport is not added to the root panel automatically. Is is not
necessary to call ResizeContainer.forceLayout()
after adding the viewport to the
RootPanel. Layout will be called after being added to the root panel.
Modifier and Type | Class and Description |
---|---|
static interface |
Viewport.ViewportAppearance |
resize, widget
forceLayoutCommand, forceLayoutOnResize, hadLayoutRunning, layoutCommand, layoutRequiredThisEventLoop, layoutRunning
adjustSize, allowTextSelection, cacheSizes, disableContextMenu, disabled, disabledStyle, ensureVisibilityOnSizing, height, hidden, lastSize, layer, left, mask, maskMessage, monitorWindowResize, pageX, pageY, resizeHandler, shim, tabIndex, toolTip, toolTipConfig, top, width, windowResizeDelay, windowResizeTask
Constructor and Description |
---|
Viewport()
Creates a viewport layout container with the default appearance.
|
Viewport(Viewport.ViewportAppearance appearance)
Creates a viewport layout container with the specified appearance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
getEnableScroll()
Returns true if window scrolling is enabled.
|
boolean |
isTouchKeyboardAdjustPan()
Returns true if the viewport is enabled to adjust for a touch keyboard by panning.
|
protected void |
onAttach() |
protected void |
onWindowResize(int width,
int height) |
void |
setEnableScroll(boolean enableScroll)
Sets whether window scrolling is enabled.
|
void |
setTouchKeyboardAdjustPan(boolean touchKeyboardAdjustPan)
This setting controls how the
Viewport responds to a touch device on-screen soft keyboard. |
add, add, doLayout, getWidget, isResize, onRemove, setElement, setResize, setWidget, setWidget
applyLayout, applyLayout, forceLayout, forceLayoutOnChildren, forceLayoutOnChildren, getLeftRightMargins, getParentLayoutWidget, getSideMargins, getTopBottomMargins, isLayoutRunning, isOrWasLayoutRunning, isWidgetVisible, onBeforeDoLayout, onLoad, onResize, onResize
addAddHandler, addBeforeAddHandler, addBeforeRemoveHandler, addContainerHandler, addRemoveHandler, adjustIndex, adopt, checkIndexBoundsForInsertion, clear, disable, doAttachChildren, doDetachChildren, doPhysicalAttach, doPhysicalDetach, enable, ensureGroupingHandlerRegistration, findWidget, getChildren, getContainerTarget, getItemByItemId, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, iterator, onInsert, onWidgetHide, onWidgetShow, orphan, remove, remove, remove
addBeforeHideHandler, addBeforeShowContextMenuHandler, addBeforeShowHandler, addBlurHandler, addDisableHandler, addEnableHandler, addFocusHandler, addGestureRecognizer, addHideHandler, addMoveHandler, addResizeHandler, addShowContextMenuHandler, addShowHandler, addStyleDependentName, addStyleOnOver, adjustPosition, adjustSize, applyState, assertAfterRender, assertPreRender, blur, clearSizeCache, disableContextMenu, disableEvents, enableEvents, fireCancellableEvent, fireEvent, focus, getData, getElement, getFocusEl, getFocusSupport, getGestureRecognizer, getGestureRecognizerCount, getHideMode, getId, getItemId, getOffsetHeight, getOffsetWidth, getPositionEl, getShadow, getShadowPosition, getStateId, getTabIndex, getToolTip, hide, hideShadow, hideToolTip, isAllowTextSelection, isAutoHeight, isAutoWidth, isDeferHeight, isEnabled, isMonitorWindowResize, isRendered, isStateful, isVisible, isVisible, mask, mask, notifyHide, notifyShow, onAfterFirstAttach, onBlur, onBrowserEvent, onDetach, onDisable, onEnable, onFocus, onHide, onHideContextMenu, onPosition, onRightClick, onShow, onShowContextMenu, onTouch, onUnload, removeStyleDependentName, removeStyleOnOver, removeToolTip, setAllowTextSelection, setBorders, setBounds, setBounds, setContextMenu, setData, setDeferHeight, setEnabled, setHeight, setHeight, setHideMode, setId, setItemId, setMonitorWindowResize, setPagePosition, setPixelSize, setPosition, setShadow, setShadowPosition, setSize, setStateful, setStateId, setStyleDependentName, setTabIndex, setToolTip, setToolTipConfig, setVisible, setWidth, setWidth, show, sync, syncSize, unmask
public Viewport()
public Viewport(Viewport.ViewportAppearance appearance)
appearance
- the appearance of the viewport layout containerpublic boolean getEnableScroll()
public boolean isTouchKeyboardAdjustPan()
public void setEnableScroll(boolean enableScroll)
enableScroll
- true to enable window scrollingpublic void setTouchKeyboardAdjustPan(boolean touchKeyboardAdjustPan)
This setting controls how the Viewport
responds to a touch device on-screen soft keyboard.
Some devices, such as iOS, will automatically pan content to make the current focus visible when part of the viewport is covered by the soft keyboard. Others, such as Android, will resize the viewport smaller to make room for the soft keyboard.
If set to true
, this instructs the Viewport
to mimic pan adjustments if the touch
device triggers a resize in response to the on-screen soft keyboard. The default value is false
.
PLEASE NOTE: This setting has no effect on devices that automatically pan content in response to the
on-screen soft keyboard. A value of false
will not cause such devices to resize —
they will always pan regardless.
touchKeyboardAdjustPan
- true to enable the viewport to adjust by panningprotected void onWindowResize(int width, int height)
onWindowResize
in class Component
Copyright © 2018. All rights reserved.