Android控件之AnalogClock、DigitalClock探究

时钟控件包括AnalogClock和DigitalClock,它们都负责显示时钟,所不同的是AnalogClock控件显示模拟时钟,且只显示时针和分针,而DigitalClock显示数字时钟,可精确到秒

以下模拟时钟的用法

目录结构

Android控件之AnalogClock、DigitalClock探究

布局文件

  
    
<? xml version = " 1.0 " encoding = " utf-8 " ?>
<!-- AnalogClock与DigitalClock这两个时钟控件都不需要Java代码,
只要在layout的xml里插入以下代码即可自动显示时间
-->
< LinearLayout xmlns:android = " http://schemas.android.com/apk/res/android "
android:orientation
= " vertical "
android:layout_width
= " fill_parent "
android:layout_height
= " fill_parent " >
<!-- 模拟时钟控件 -->
< AnalogClock android:id = " @+id/analogClock "
android:layout_width
= " wrap_content "
android:layout_height
= " wrap_content "
android:layout_gravity
= " center_horizontal " />
<!-- 数字时钟控件 -->
< DigitalClock android:id = " @+id/digitalClock "
android:layout_width
= " wrap_content "
android:layout_height
= " wrap_content "
android:layout_gravity
= " center_horizontal " />
</ LinearLayout >

运行结果

Android控件之AnalogClock、DigitalClock探究

你可能感兴趣的:(android控件)