English | Site Directory

Android - An Open Handset Alliance Project

android.widget
public class

android.widget.ZoomSlider

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
android.widget.ZoomSlider

The ZoomSlider class displays a vertical slider with marks to denote different zoom levels. It can be configured to display various ranges and will dynamically display different marks on the slider based on the given range. The caller must supply a ZoomSlider.OnZoomChangedListener to be notified of changes to the zoom level.

Using ZoomSlider

  • Instantiate: ZoomSlider zoomSlider = new ZoomSlider();
  • Create a ZoomSlider.OnZoomChangedListener: OnZoomChangedListener zoomListener = new MyZoomListener();
  • Set your zoom parameters: zoomSlider.setParams(1, 11, zoomListener);
  • Display: You can use the ZoomSlider like any other view and add to your existing view or display in a Dialog

Nested Classes
ZoomSlider.OnZoomChangedListener

The OnZoomChangedListener is used as a callback to be notified when the user has changed the zoom level. 

Summary

XML Attributes

Attribute name Related methods  
android:current   The current zoom value, this is where the slider will be initially positioned i.e. 
android:end   The last value of the zoom range (inclusive) i.e. 
android:minSegmentSpace   The minimum amount of spacing between the zoom segments

This corresponds to the global attribute resource symbol minSegmentSpace

android:notifyOnZoom   true if the callback should be called every time the zoom level is changed by the user, false if the callback should only be called after the user has selected a zoom level

Must be a boolean value, either "true" or "false". 

android:segment   The color of the segment

May be a reference to another resource, in the form "@[[]+][[]package:]type:name" or to a theme attribute in the form "?[[]package:][[]type:]name". 

android:segmentLength   The length of segment

This corresponds to the global attribute resource symbol segmentLength

android:segmentWidth   The width of segment

This corresponds to the global attribute resource symbol segmentWidth

android:slider   The color of the slider

May be a reference to another resource, in the form "@[[]+][[]package:]type:name" or to a theme attribute in the form "?[[]package:][[]type:]name". 

android:sliderLength   The length of slider which shows the currently selected zoom level

This corresponds to the global attribute resource symbol sliderLength

android:sliderWidth   The width of slider which shows the currently selected zoom level

This corresponds to the global attribute resource symbol sliderWidth

android:start   The first value of the zoom range (inclusive) i.e. 
android:trackBackground   The background of the track

This corresponds to the global attribute resource symbol trackBackground

android:trackLength   The length of the zoom track on which the slider and segments are displayed

This corresponds to the global attribute resource symbol trackLength

android:zoomInIcon   The icon displayed for zooming in

Must be a reference to another resource, in the form "@[[]+][[]package:]type:name" or to a theme attribute in the form "?[[]package:][[]type:]name". 

android:zoomInPaddingBottom   The bottom padding for the zoom in icon

This corresponds to the global attribute resource symbol zoomInPaddingBottom

android:zoomInPaddingLeft   The left padding for the zoom in icon

This corresponds to the global attribute resource symbol zoomInPaddingLeft

android:zoomInPaddingRight   The right padding for the zoom in icon

This corresponds to the global attribute resource symbol zoomInPaddingRight

android:zoomInPaddingTop   The top padding for the zoom in icon

This corresponds to the global attribute resource symbol zoomInPaddingTop

android:zoomInPressedIcon   The icon in pressed state displayed for zooming in

Must be a reference to another resource, in the form "@[[]+][[]package:]type:name" or to a theme attribute in the form "?[[]package:][[]type:]name". 

android:zoomOutIcon   The icon displayed for zooming out

Must be a reference to another resource, in the form "@[[]+][[]package:]type:name" or to a theme attribute in the form "?[[]package:][[]type:]name". 

android:zoomOutPaddingBottom   The bottom padding for the zoom out icon

This corresponds to the global attribute resource symbol zoomOutPaddingBottom

android:zoomOutPaddingLeft   The left padding for the zoom out icon

This corresponds to the global attribute resource symbol zoomOutPaddingLeft

android:zoomOutPaddingRight   The right padding for the zoom out icon

This corresponds to the global attribute resource symbol zoomOutPaddingRight

android:zoomOutPaddingTop   The top padding for the zoom out icon

This corresponds to the global attribute resource symbol zoomOutPaddingTop

android:zoomOutPressedIcon   The icon in pressed state displayed for zooming out

Must be a reference to another resource, in the form "@[[]+][[]package:]type:name" or to a theme attribute in the form "?[[]package:][[]type:]name". 

XML Attributes inherited from class android.view.View
Constants inherited from class android.view.View
Fields inherited from class android.view.View

Public Constructors

          ZoomSlider(Context context)
          ZoomSlider(Context context, AttributeSet attrs, Map inflateParams)
          ZoomSlider(Context context, AttributeSet attrs, Map inflateParams, int defStyle)

Public Methods

        void  doZoom(boolean in)
Move the zoom up or down by 1.
    final    int  getCurrent()
    final    float  getCurrentPercent()
    final    int  getCurrentY()
    final    int  getMax()
    final    int  getMin()
    final    int  getRange()
        boolean  onKeyDown(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view when KEYCODE_DPAD_CENTER or KEYCODE_NEWLINE is released, if the view is enabled and clickable.
        boolean  onTouchEvent(MotionEvent event)
Implement this method to handle touch screen motion events.
        void  onZoomCompleted()
Called by the Dialog once the user has completed zooming and has dismissed the dialog.
    final    int  setCurrent(int level)
Sets the level on the zoom slider.
        void  setOnZoomChangedListener(OnZoomChangedListener zoomListener)
Sets just the ZoomSlider.OnZoomChangedListener, this should be used when all the other parameters in the setParams(int, int, int, android.widget.ZoomSlider.OnZoomChangedListener, boolean) are specified in the xml file.
        void  setParams(int start, int end, int current, OnZoomChangedListener zoomListener, boolean notifyOnChange)
Set the parameters for this ZoomSlider.

Protected Methods

        void  onDraw(Canvas canvas)
Implement this to do your drawing.
        void  onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

Methods inherited from class android.view.View