Could I write text vertically as in japanese script, is it possible at all? [duplicate]
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?
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
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 + ' '
} else {
t = t + h[j];
}
if (j < k - 1) {
t = t + ' ';
}
}
s[i].innerHTML = t;
}
}
}(document));
</script>
</body>
</html>
精彩评论