public class ZoomButtonsController extends Object implements View.OnTouchListener
ZoomButtonsController
handles showing and hiding the zoom
controls and positioning it relative to an owner view. It also gives the
client access to the zoom controls container, allowing for additional
accessory buttons to be shown in the zoom controls window.
Typically, clients should call setVisible(true)
on a touch down or move (no need to call setVisible(false)
since it will time out on its own). Also, whenever the
owner cannot be zoomed further, the client should update
setZoomInEnabled(boolean)
and setZoomOutEnabled(boolean)
.
If you are using this with a custom View, please call
setVisible(false)
from
View.onDetachedFromWindow()
and from View.onVisibilityChanged(android.view.View, int)
when visibility != View.VISIBLE
.
Modifier and Type | Class and Description |
---|---|
static interface |
ZoomButtonsController.OnZoomListener
Interface that will be called when the user performs an interaction that
triggers some action, for example zooming.
|
Constructor and Description |
---|
ZoomButtonsController(View ownerView)
Constructor for the
ZoomButtonsController . |
Modifier and Type | Method and Description |
---|---|
ViewGroup |
getContainer()
Gets the container that is the parent of the zoom controls.
|
View |
getZoomControls()
Gets the view for the zoom controls.
|
boolean |
isAutoDismissed()
Whether the zoom controls will be automatically dismissed after showing.
|
boolean |
isVisible()
Whether the zoom controls are visible to the user.
|
boolean |
onTouch(View v,
MotionEvent event)
Called when a touch event is dispatched to a view.
|
void |
setAutoDismissed(boolean autoDismiss)
Sets whether the zoom controls will be automatically dismissed after
showing.
|
void |
setFocusable(boolean focusable)
Sets whether the zoom controls should be focusable.
|
void |
setOnZoomListener(ZoomButtonsController.OnZoomListener listener)
Sets the
ZoomButtonsController.OnZoomListener listener that receives callbacks to zoom. |
void |
setVisible(boolean visible)
Sets whether the zoom controls should be visible to the user.
|
void |
setZoomInEnabled(boolean enabled)
Whether to enable the zoom in control.
|
void |
setZoomOutEnabled(boolean enabled)
Whether to enable the zoom out control.
|
void |
setZoomSpeed(long speed)
Sets the delay between zoom callbacks as the user holds a zoom button.
|
public ZoomButtonsController(View ownerView)
ZoomButtonsController
.ownerView
- The view that is being zoomed by the zoom controls. The
zoom controls will be displayed aligned with this view.public void setZoomInEnabled(boolean enabled)
enabled
- Whether to enable the zoom in control.public void setZoomOutEnabled(boolean enabled)
enabled
- Whether to enable the zoom out control.public void setZoomSpeed(long speed)
speed
- The delay in milliseconds between zoom callbacks.public void setOnZoomListener(ZoomButtonsController.OnZoomListener listener)
ZoomButtonsController.OnZoomListener
listener that receives callbacks to zoom.listener
- The listener that will be told to zoom.public void setFocusable(boolean focusable)
focusable
- Whether the zoom controls should be focusable.public boolean isAutoDismissed()
public void setAutoDismissed(boolean autoDismiss)
public boolean isVisible()
public void setVisible(boolean visible)
visible
- Whether the zoom controls should be visible to the user.public ViewGroup getContainer()
The client can add other views to this container to link them with the zoom controls.
public View getZoomControls()
public boolean onTouch(View v, MotionEvent event)
View.OnTouchListener
onTouch
in interface View.OnTouchListener
v
- The view the touch event has been dispatched to.event
- The MotionEvent object containing full information about
the event.