本文承接,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 = ".&