Code example for ZoomButtonsController

Methods: getZoomControlssetOnZoomListenersetZoomInEnabledsetZoomOutEnabled

0
        } 
        boolean canZoomIn = mAwContents.canZoomIn();
        boolean canZoomOut = mAwContents.canZoomOut();
        if (!canZoomIn && !canZoomOut) {
            // Hide the zoom in and out buttons if the page cannot zoom 
            zoomController.getZoomControls().setVisibility(View.GONE);
        } else { 
            // Set each one individually, as a page may be able to zoom in or out 
            zoomController.setZoomInEnabled(canZoomIn);
            zoomController.setZoomOutEnabled(canZoomOut);
        } 
    } 
 
    // This method is used in tests. It doesn't modify the state of zoom controls. 
    View getZoomControlsViewForTest() {
        return mZoomButtonsController != null ? mZoomButtonsController.getZoomControls() : null;
    } 
 
    private ZoomButtonsController getZoomController() {
        if (mZoomButtonsController == null &&
            mAwContents.getSettings().shouldDisplayZoomControls()) {
            mZoomButtonsController = new ZoomButtonsController(
                    mAwContents.getContentViewCore().getContainerView());
            mZoomButtonsController.setOnZoomListener(new ZoomListener());
            // ZoomButtonsController positions the buttons at the bottom, but in 
            // the middle. Change their layout parameters so they appear on the 
            // right. 
            View controls = mZoomButtonsController.getZoomControls();
            ViewGroup.LayoutParams params = controls.getLayoutParams();
            if (params instanceof FrameLayout.LayoutParams) {
                ((FrameLayout.LayoutParams) params).gravity = Gravity.RIGHT;
            } 
        }