Android Chinese API (16) -- analogclock

Source: Internet
Author: User

Preface

Keywords: Android. widget. analogclock, Android 2.2 R1 analogclock, analogclock API

This chapter translates Android. widget. analogclock into a clock/analog clock. Starting from this chapter, the translation series officially changed to "android Chinese ?", For example, the current series of "android Chinese API", in addition to someone in the translation test related content, welcome to participate in the android API Chinese translation operations, contact me over140@gmail.com.

 

Statement

You are welcome to repost, but please keep the original source of the article :)

Blog: http://www.cnblogs.com

Farmer's uncle: http://www.cnblogs.com/over140/

 

Version

Android 2.2 r1

 

Body

I. Structure

    Public class analogclock extends View

 

Java. Lang. Object

Android. View. View

Android. widget. analogclock

 

Ii. Category Overview

    

This is a analog clock control with the hour and minute hands.

 

Iii. Protected Methods

Protected void onattachedtowindow ()

Called when a view (analogclock) is attached to a form. When called, the view is displayed on the surface of the form and is drawn. Ensure that this method is called before ondraw (canvas), but it can be called any time before or after ondraw (INT, INT.

 

Protected void ondetachedfromwindow ()

It is called when a view (digitalclock) is detached (removed) from a form, and a view is no longer drawn on the form surface.

 

Protected void ondraw (canvas)

Implement your own rendering.

Parameters

Canvas draws the background on the canvas

 

Protected void onmeasure (INT widthmeasurespec, int heightmeasurespec)

Measure this view to determine the height and width of its content. This method is called Through measure (INT, INT) and should be rewritten by subclass to improve the efficiency and accuracy of content measurement.

Convention: When this method is overwritten, you must call setmeasureddimension (INT, INT) to store the height and width of the measured view. Otherwise, an illegalstateexception is thrown through measure (INT, INT. It is an effective method to call the onmeasure (INT, INT) method of the parent class.

The implementation of the parent class is based on the Default background size, unless measurespec (measurement rules) allows a larger background. To better measure the content subclass, override onmeasure (INT, INT ).

If this method is overwritten, The subclass has the responsibility to ensure that the height and width of the measurement are at least the minimum width and height of the view (getsuggestedminimumheight () and getsuggestedminimumwidth ()).

Parameters

Widthmeasurespec because the parent class has horizontal space requirements, see view. measurespec.

Heightmeasurespec because the parent class has vertical space requirements, see view. measurespec.

 

Protected void onsizechanged (int w, int H, int oldw, int oldh)

Called when the View Size changes during layout. If only the view is added, the old value 0 is displayed during the call. (Note: when added to the view, the values of oldw and oldh are 0)

Parameters

W view current width

H view current height

Previous width of the oldw View

Previous height of the oldh View

 

Iv. PDF download

Http://download.csdn.net/source/2772172 (csdn)

  

End

At present, there are 15 members in the translation group, and the plan is in progress. We look forward to the arrival of 51 members on that day. You are welcome to join us.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.