如何在Android的TextView中的任一端插入文本? [英] How to insert text at either end of the android textview?
问题描述
是否有可能有一个包含在最左侧的一些文字,并在TextView中的最右侧一些文本一个TextView。
例如:我想有哪些应该出现这样的
/////////////////
文字         一个
////////////////
Is it possible to have a textview which contains some text at the leftmost side and some text at the rightmost side of the textview.
For Example: I want to have a textview which should appear like this
/////////////////
text a
////////////////
推荐答案
它使用一个单一的TextView是可能的。
只要把HTML格式的文本像
It is possible using a single TextView. Just put the text in HTML format like
<string name="my_string">
<![CDATA[
<!DOCTYPE html>
<html>
<body>
<h1><span>Sunil bn</span><span style="float:right">Your Text</span></h1>
</body>
</html>
]]>
</string>
在字符串文件。假设字符串的名称是my_string。然后在你的code。使用设置TextView的文本
in the strings file. Suppose the name of the string is "my_string". Then in your code set the text on the TextView using
myTextView.setText(Html.fromHtml(getResources()
.getString(R.string.my_string)));
这篇关于如何在Android的TextView中的任一端插入文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!