Android 从小白到大拿之路——数字时钟和虚拟时钟的实现

来源:互联网 发布:手机淘宝怎么提交改价 编辑:程序博客网 时间:2024/03/28 17:01

OMG,我一开始以为虚拟时钟会很难实现,结果是这么的easy,xixi.

在需在Layout中添加相应的时钟控件,并根据自己的需求设置相关属性就OK了,代码如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:gravity="center_horizontal"    android:orientation="vertical"    tools:context="com.example.demo.MainActivity" >    <AnalogClock        android:layout_width="wrap_content"        android:layout_height="wrap_content" />    <DigitalClock        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:textSize="14pt"         /></LinearLayout>



在虚拟机的运行情况如下:


0 0