3

I want to write text vertical, but not to rotate it - example:

H
e
l
l
o

Could be this done in some specific way in android or I should add a new line after each and every letter of the word?

Zoe
  • 27,060
  • 21
  • 118
  • 148
nenito
  • 1,214
  • 6
  • 19
  • 33

2 Answers2

1

If you are only writing a few things have each letter on its own line may be easier. You can use /n after every character to have each letter move to a different line. I am unfamiliar with a way to do ith without rotation unless you make a vertical textview that can only fit one letter per line(width = very small)

This old SO post may give you some more insight if you are intereted in doing it this way. (It does involve rotation)

Write Vertical on Canvas

This tutorial was linked to on the above SO post

Tutorial

Community
  • 1
  • 1
sealz
  • 5,348
  • 5
  • 40
  • 70
  • So there is now other way and I should add a new line!?? 10x – nenito Aug 03 '11 at 18:17
  • 1
    @nenito nothing that I know(accept a very small width and make the textview vertical :), someone else will weigh in in a bit I am sure. – sealz Aug 03 '11 at 18:18
1

If you're not averse to a bit of JavaScript post-processing, this will do what you want:

<html>      
<head> 
   <title>Vertical Text</title>
   <style>
   .vert { 
      width: 0;
      display: inline-block;
   }
   </style>   
</head>
<body>
<span class="vert">this is a test</span> 
<script type="text/javascript">
   (function (d) {
      var s = d.getElementsByTagName('SPAN');  
      for (var i = 0, n = s.length; i < n; i = i + 1) {  
         if (s[i].className === 'vert') {  
            var h = s[i].innerHTML; 
            var t = '';
            for (var j = 0, k = h.length; j < k; j = j + 1) { 
               if (h[j] === ' ') {   
                  t = t + '&nbsp;'
               } else {
                  t = t + h[j];
               }     
               if (j < k - 1) { 
                  t = t + ' ';
               }   
            }
            s[i].innerHTML = t;
         }
      }
   }(document));  
</script>  
</body>
</html>
Kent Brewster
  • 2,480
  • 2
  • 22
  • 27