0

I am unable to align text in a table format in my dashclock extension's body. Following is the format I want (first column left aligned, rest columns right aligned):

   A               2               3
   BC              5              10
   DEF            22               3

In the code I try aligning the following way

String.format("%-10s %10s %10s\n", val1, val2, val3);

When I log the result of the above formatting it prints in the correct and intended way in logcat. But when I deploy the app and run it as part of the dashclock application, the alignment is completely off. The alignment when displayed in dashclock extension looks like:

   A           2               3
   BC            5              10
   DEF            22               3

I tried searching and looking into the DashClockExtension class to see if something is possible but couldn't. Also the expandedBody method in ExtensionData does not take SpannedString as argument, only String.

Any ideas as how to get the alignment right in the device?

Prasanna
  • 3,703
  • 9
  • 46
  • 74

1 Answers1

2

There isn't currently a way to do this because the font used for displaying expanded body content isn't a monospace font, meaning each character has a different width. Feel free to file a feature request for representing tabular data though! http://dashclock.com/issues

Roman Nurik
  • 29,665
  • 7
  • 84
  • 82
  • Okay. Will it make much more sense to file the feature request for html support in expanded body text instead of just tabular data? – Prasanna May 02 '13 at 04:12
  • Hm, supporting full HTML in the widget is likely not possible, but monochrome or otherwise tabular data *may* be possible, depending on how important/broad the use case is. – Roman Nurik May 02 '13 at 13:59