在TextView中多重比对? [英] Multiple alignment in TextView?

查看:168
本文介绍了在TextView中多重比对?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像下面一个TextView。 我用这个code将灰色文本的一部分。

I have a TextView like below. I used this code to set gray color for a part of the text.

// Prepare result text.
final String resultText = text + "\n\n" + dictionaryName;
final SpannableString styledResultText = new SpannableString(resultText);
styledResultText.setSpan(new ForegroundColorSpan(Color.GRAY), text.length() + 2, text.length() + 2 + dictionaryName.length(), 0);
resultTextView.setText(styledResultText);

现在我想集齐了它。怎么做? Android不具备任何跨类调整。我找不到任何东西像AlignmentSpan。

Now I want to set align for it. How to do? Android doesn't have any span class for alignment. I can't find out anything like "AlignmentSpan".

推荐答案

AFAIK,这是不可能的。我真的希望能发展为那些为两个不同的领域。好像你有分离的数据,为什么不直接创造的灰色文本(dictionaryName)?一个独立的TextView

AFAIK this is not possible. I would really aim to have those as two different fields. It seems like you have the data separated, why not just create a separate TextView for the grey text (dictionaryName)?

我曾尝试使用spannables尽可能少因为这个原因。

I have tried to use spannables as less as possible for this very reason.

这篇关于在TextView中多重比对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆