Most visited

Recently visited

Added in API level 1
Deprecated since API level 23

AnalogClock

public class AnalogClock
extends View

java.lang.Object
   ↳ android.view.View
     ↳ android.widget.AnalogClock


This class was deprecated in API level 23.
This widget is no longer supported.

This widget display an analogic clock with two hands for hours and minutes.

Summary

XML attributes

android:dial  
android:hand_hour  
android:hand_minute  

Inherited XML attributes

From class android.view.View

Inherited constants

From class android.view.View

Inherited fields

From class android.view.View

Public constructors

AnalogClock(Context context)
AnalogClock(Context context, AttributeSet attrs)
AnalogClock(Context context, AttributeSet attrs, int defStyleAttr)
AnalogClock(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Protected methods

void onAttachedToWindow()

This is called when the view is attached to a window.

void onDetachedFromWindow()

This is called when the view is detached from a window.

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.

void onSizeChanged(int w, int h, int oldw, int oldh)

This is called during layout when the size of this view has changed.

Inherited methods

From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

XML attributes

android:dial

android:hand_hour

android:hand_minute

Public constructors

AnalogClock

Added in API level 1
AnalogClock (Context context)

Parameters
context Context

AnalogClock

Added in API level 1
AnalogClock (Context context, 
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

AnalogClock

Added in API level 1
AnalogClock (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context
attrs AttributeSet
defStyleAttr int

AnalogClock

Added in API level 21
AnalogClock (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context
attrs AttributeSet
defStyleAttr int
defStyleRes int

Protected methods

onAttachedToWindow

Added in API level 1
void onAttachedToWindow ()

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).

onDetachedFromWindow

Added in API level 1
void onDetachedFromWindow ()

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.

onDraw

Added in API level 1
void onDraw (Canvas canvas)

Implement this to do your drawing.

Parameters
canvas Canvas: the canvas on which the background will be drawn

onMeasure

Added in API level 1
void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int, int). Calling the superclass' onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec int: horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec int: vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.

onSizeChanged

Added in API level 1
void onSizeChanged (int w, 
                int h, 
                int oldw, 
                int oldh)

This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.

Parameters
w int: Current width of this view.
h int: Current height of this view.
oldw int: Old width of this view.
oldh int: Old height of this view.

Hooray!