本文承接,Android 开发第五弹:简易时钟(闹钟) 和 Android 开发第六弹:简易时钟(计时器),这一部分是关于秒表的。
布局
同样是新建一个类(StopWatchView)并扩展自LinearLayout,并将其用作布局。
<myapplication.nomasp.com.clock.StopWatchView
android : id = "@+id/tabStopWatch"
android : layout_width = "match_parent"
android : layout_height = "match_parent"
android : orientation = "vertical">
<LinearLayout
android : layout_width = "match_parent"
android : layout_height = "wrap_content"
android : orientation = "horizontal">
<TextView
android : id = "@+id/tvHour"
android : layout_width = "0dp"
android : layout_height = "wrap_content"
android : layout_weight = "1"
android : textAppearance = "?android:attr/textAppearanceLarge" / >
<TextView
android : text = ":"
android : layout_width = "wrap_content"
android : layout_height = "wrap_content"
android : textAppearance = "?android:attr/textAppearanceLarge" / >
<TextView
android : id = "@+id/tvMinute"
android : layout_width = "0dp"
android : layout_height = "wrap_content"
android : layout_weight = "1"
android : textAppearance = "?android:attr/textAppearanceLarge" / >
<TextView
android : text = ":"
android : layout_width = "wrap_content"
android : layout_height = "wrap_content"
android : textAppearance = "?android:attr/textAppearanceLarge" / >
<TextView
android : id = "@+id/tvSecond"
android : layout_width = "0dp"
android : layout_height = "wrap_content"
android : layout_weight = "1"
android : textAppearance = "?android:attr/textAppearanceLarge" / >
<TextView
android : text = "."
android : layout_width = "wrap_content"
android : layout_height = "wrap_content"
android : textAppearance =

本文介绍如何在Android中创建一个简易秒表。通过新建StopWatchView类,扩展LinearLayout,实现秒表功能。代码已上传至Github,欢迎交流与贡献。
最低0.47元/天 解锁文章
9062

被折叠的 条评论
为什么被折叠?



