做企业网站通常哪找素材,西安网站代维护,网站备案在哪个部门,中国建设银行北京分行网站TextClock 继承 TextView #xff0c;使用方法和 TextView 一样。
它专门用于显示数字时钟#xff0c;可以自定义显示格式。
只要在布局文件里添加#xff0c;它会自动更新时间#xff0c;不需要添加刷新逻辑。
布局文件#xff0c;
?xml version1.0…TextClock 继承 TextView 使用方法和 TextView 一样。
它专门用于显示数字时钟可以自定义显示格式。
只要在布局文件里添加它会自动更新时间不需要添加刷新逻辑。
布局文件
?xml version1.0 encodingutf-8?
LinearLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:apphttp://schemas.android.com/apk/res-autoxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:orientationverticalLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:text未设置Format:android:textColorandroid:color/blackandroid:textSize30sp /TextClockandroid:idid/textclock0android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textColor#4B5C92android:textSize30sp //LinearLayoutLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textyyyy/MM/dd EEEE HH:mm:ss : android:textColorandroid:color/blackandroid:textSize30sp /TextClockandroid:idid/textclock1android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:format12Houryyyy/MM/dd EEEE hh:mm:ssandroid:format24Houryyyy/MM/dd EEEE HH:mm:ssandroid:textColor#4B5C92android:textSize30sp //LinearLayoutLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textyyyy/M/dd EEE HH:mm:ss : android:textColorandroid:color/blackandroid:textSize30sp /TextClockandroid:idid/textclock2android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:format12Houryyyy/M/dd EEE hh:mm:ssandroid:format24Houryyyy/M/dd EEE HH:mm:ssandroid:textColor#4B5C92android:textSize30sp //LinearLayoutLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textMM dd EEEE HH:mm : android:textColorandroid:color/blackandroid:textSize30sp /TextClockandroid:idid/textclock3android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:format12HourMM dd EEEE hh:mmandroid:format24HourMM dd EEEE HH:mmandroid:textColor#4B5C92android:textSize30sp //LinearLayoutLinearLayoutandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:orientationhorizontalTextViewandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textMMM dd EEE HH:mm :android:textColorandroid:color/blackandroid:textSize30sp /TextClockandroid:idid/textclock4android:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:format12HourMMM dd EEE HH:mmandroid:format24HourMMM dd EEE HH:mmandroid:textColor#4B5C92android:textSize30sp //LinearLayout/LinearLayout实际效果 中文24小时制
总结
如果不设置 android:format12Hour 、android:format24Hour 默认以 12:48 格式显示。
如果设置了 format 参考表格
格式效果yyyy/M/dd2024/6/25yyyy/MM/dd2024/06/25MMM6月EEE中文显示周几英文显示星期缩写如 ThuEEEE中文显示星期几英文显示星期完整拼写如 ThurdayHH:mm:ss15:32:16hh:mm:ss03:32:16a是否显示 AM/PM