Android Learning notes _s01_e02 AnalogClock and DigitalClock (clock) features and usage

Source: Internet
Author: User

First, the basic definition

AnalogClock and DigitalClock are two very simple components, and DigitalClock itself is a text box, except that the content shown in it is time, but the Android:text attribute of DigitalClock doesn't work. The AnalogClock inherits the view component, overrides the view's OnDraw method, and draws the analog clock on the view.

Second, the attribute

A description of the XML attributes supported by AnalogClock.

XML properties Description
Android:dial Set the picture used for the analog clock's dial
Android:hand_hour Set the analog clock to the hour dial using the picture
Android:hand_minute Set the hand image of the analog clock with the minute hand
Third, the realization effectIv. The process of writing

AnalogClock and DigitalClock are relatively simple to write, simply put the appropriate controls in the XML file, and reference the relevant picture based on the attribute.

1. Create a new DigitalClock control in the XML file.

1 <2         android:id= "@+id/digitalclock"3         android:layout_width= "Wrap_ Content "4         android:layout_height=" Wrap_content "5         android:textsize=" 30SP "6         android:isscrollcontainer= "true"/>
View Code

2. Create a new AnalogClock control. The Dial property controls the dial style, found through "@Drawable/Picture", Hand_hour and minute control pointer styles, found through "@Drawable/pictures".

1 <2         android:id= "@+id/analogclock"3         android:layout_width= "Wrap_ Content "4         android:layout_height=" Wrap_content "5         android:dial=" @drawable/watch "6          android:hand_hour= "@drawable/hand"7         android:hand_minute= "@drawable/hand"/>
View CodeFive, source code

XML file, other code does not change

1<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"2Xmlns:tools= "Http://schemas.android.com/tools"3Android:layout_width= "Match_parent"4android:layout_height= "Match_parent"5android:orientation= "Vertical"6Tools:context= ". Mainactivity ">7 8<DigitalClock9Android:id= "@+id/digitalclock"TenAndroid:layout_width= "Wrap_content" Oneandroid:layout_height= "Wrap_content" AAndroid:textsize= "30SP" -Android:isscrollcontainer= "true"/> -      the<AnalogClock -Android:id= "@+id/analogclock" -Android:layout_width= "Wrap_content" -android:layout_height= "Wrap_content" +Android:dial= "@drawable/watch" -Android:hand_hour= "@drawable/hand" +Android:hand_minute= "@drawable/hand"/> A  at</LinearLayout>
View Code

Android Learning notes _s01_e02 AnalogClock and DigitalClock (clock) features and usage

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.