This guide assumes that you can decompile & recompile apks.
Whilst theming my statusbar clock and running into a couple of smali problems, @Ticklefish suggested I look at TextClock - an extension to TextView that was introduced in Android 4.2
TextClock can display the current time and/or date as a formatted string using both 12-hour and 24-hour modes and makes a great drop-in replacement for the normal statusbar clock.
The statusbar clock code is contained in the com.android.systemui.statusbar.policy.Clock code block in SystemUI.apk\res\layout\status_bar.xml and we can replace this with a TextClock code block:
The important bits here are the format strings:
which shows as Fri 8:26 PM
which shows as Fri 20:26
You can use a combination of the options below to create your preferred format:
One advantage of using TextClock is that if you move the android:format strings into string resources, you can embed simple HTML into the strings to enhance the result
So replace:
with:
and add two strings to the bottom of SystemUI.apk\res\values\strings.xml,
these can then be styled using HTML
Example:
which shows as
as the base font size was 18.0dip
which shows as
as the base font size was 18.0dip
Other styling is handled normally, either in-line or in an external style resource in SystemUI.apk\res\values\styles.xml
Embedding HTML in string resources will also work in a normal TextView and there are a few additional tags you can use. REFERENCE
Note: Setting android:textAllCaps="true" inline or <item name="android:textAllCaps">true</item> in your external style resource will break the HTML embedded in the XML strings as this HAS to be in lowercase for it to be parsed.
Whilst theming my statusbar clock and running into a couple of smali problems, @Ticklefish suggested I look at TextClock - an extension to TextView that was introduced in Android 4.2
TextClock can display the current time and/or date as a formatted string using both 12-hour and 24-hour modes and makes a great drop-in replacement for the normal statusbar clock.
The statusbar clock code is contained in the com.android.systemui.statusbar.policy.Clock code block in SystemUI.apk\res\layout\status_bar.xml and we can replace this with a TextClock code block:
Code:
<TextClock android:format12Hour=@string/status_bar_expanded_clock_12hr_format" android:format24Hour=@string/status_bar_expanded_clock_24hr_format" android:textAppearance=@style/TextAppearance.StatusBar.Expanded.Clock" android:id="@id/clock" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom" android:layout_marginTop="-3.0dip" android:layout_marginLeft="@dimen/notification_panel_header_clock_margin_left" android:singleLine="true" />
Code:
android:format12Hour="EEE h:mm a"
Code:
android:format24Hour="EEE HH:mm"
You can use a combination of the options below to create your preferred format:
Quote:
d.............Day Of Month (single digit) 7 dd.......... Day Of Month (double digit) Zero, 07 EEEE......Day Of Week (Full) Monday EEE........Week Day (Short) Mon MMMM....Month (Full) AUGUST MMM.......Month (Short) AUG MM..........Month (double digit) 08 M............Month (Single digit) 8 yyyy........Year (Full) 2013 yy............Year (Short) 13 h..............Hour (12 hour, single digit) 8 hh............Hour (12 hour, double digit) 08 H.............Hour (24 hour, single digit) 8 20 HH...........Hour (24 hour, double digit) 08 20 m.............Minute (single digit) 9 MM..........Minute (double digit) 09 s..............Second (single digit) 9 ss............Second (double digit) 09 a..............Marker AM/PM |
So replace:
Code:
android:format12Hour="EEE h:mm a" android:format24Hour="EEE HH:mm"
Code:
android:format12Hour=@string/status_bar_clock_12hr_format" android:format24Hour=@string/status_bar_clock_24hr_format"
Code:
<string name="status_bar_clock_12hr_format">EEE h:mm a</string>
<string name="status_bar_clock_24hr_format">EEE HH:mm</string>
Quote:
<b>...</b> ..................................makes the the enclosed text bold <i>...</i> ...................................makes the the enclosed text italic <font size ="X">...</font> ............sets the font size of the enclosed text to X.0dip <font fgcolor ="#ffffffff">...</> ........sets the foreground colour of the enclosed text <font bgcolor ="#ff000000">...</> .sets the background colour of the enclosed text |
Code:
<string name="status_bar_clock_12hr_format"><font size="12">EEE </font>h:mm<font size="12"> a</font></string>

Code:
<string name="status_bar_clock_24hr_format"><font size="12">EEE </font>HH:mm</string>

Other styling is handled normally, either in-line or in an external style resource in SystemUI.apk\res\values\styles.xml
Code:
android:textAppearance=@style/TextAppearance.StatusBar.Clock"
Note: Setting android:textAllCaps="true" inline or <item name="android:textAllCaps">true</item> in your external style resource will break the HTML embedded in the XML strings as this HAS to be in lowercase for it to be parsed.