时钟(AnalogClock和TextClock)的功能和用法
2016-03-10 10:51
411 查看
时钟UI组件是两个非常简单的组件:TextClock本身就继承了TextView,也就是说,他本身就是文本框,只是他里面显示的内容总是当前的时间。
与TextView不用的是,为TextClock设置android:text属性没什么作用。
实例:手机里的“劳力士”。
界面布局文件如下。
运行结果如下。
与TextView不用的是,为TextClock设置android:text属性没什么作用。
实例:手机里的“劳力士”。
界面布局文件如下。
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.example.l2112.clocktest.MainActivity" tools:showIn="@layout/activity_main" android:orientation="vertical" android:gravity="center_horizontal"> <!--定义模拟时钟--> <AnalogClock android:layout_width="wrap_content" android:layout_height="wrap_content" /> <!--定义数字时钟--> <TextClock android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="10pt" android:textColor="#f0f" android:format24Hour="yyyy年MM月dd日 H:mma EEEE" /> <!--定义模拟时钟,并使用自定义表盘、时针图片--> <AnalogClock android:layout_width="wrap_content" android:layout_height="wrap_content" android:dial="@drawable/watch" android:hand_minute="@drawable/hand"/> </LinearLayout>
运行结果如下。
相关文章推荐
- 从源码的角度探究Activity的启动过程
- hellocharts 柱状图实例
- Java newInstance(); 报 java.lang.NullPointerException 异常
- 一个Android开发工具集成网址
- 理解Fragment生命周期
- Qt5 中的QPainterPath类的功能和使用方法
- 互斥锁 条件变量 读写锁
- SVN使用教程总结
- [COGS 362]锯木厂选址
- 两个220V电平测试电路的比较
- 欢迎使用CSDN-markdown编辑器
- ICP 算法步骤
- iOS 链式编程/函数式编程写法
- CocoaPods的使用,安装第三方SDK
- 课程project总结 - 目录
- ASCII与unicode
- zookeeper 分布式锁服务
- FAST+BRIEF原理简介
- java 异步请求转同步结果
- Android 轮播里面的 RadioButton 的 自定义