理由无法正常运行的TextView文本 [英] justify text in textview not working properly
问题描述
我正在从 TextJustify-的Android 参考。我执行选项2 在上面的链接。当我跑我在模拟器文本应用程序出现在一行一个词,在下一行等下一个单词。我不知道什么是错在我的code。请帮我。谢谢你。
I am taking reference from TextJustify-Android. I am implementing option 2 in above link. When I run my app on emulator text appears one word in one line, next word in next line and so on. I dont know whats wrong in my code. Please help me. Thanks.
Activity类code -
Activity class code-
textView1 = (TextView) findViewById (R.id.textView1);
textView1.setMovementMethod(new ScrollingMovementMethod());
textView1.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener()
{
boolean isJustified = false;
@Override
public boolean onPreDraw()
{
if(!isJustified)
{
TextJustifyUtils.run(textView1,0);
isJustified = true;
}
return true;
}
});
XML code -
Xml code-
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="8"
android:gravity="center">
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="vertical"
android:text="@string/his"
android:textColor="#FFFFFF"/>
</LinearLayout>
和我在执行 TextJustifyUtils
类在我的应用程序在上面的链接建议。
And I am implementing TextJustifyUtils
class in my app as suggested in above link.
我已经做了一个变化在 TextJustifyUtils.run(textView1)鉴于链接;
在我的code日食建议我在 TextJustifyUtils.run(textView1,0);
。是什么问题呢?
I have made one change In that link given TextJustifyUtils.run(textView1);
and In my code eclipse suggest me to change in TextJustifyUtils.run(textView1,0);
. Is anything wrong with this?
更新:
在 TextJustifyUtils
更改公共静态无效的理由(TextView中的TextView)
到公共静态无效的run(TextView中的TextView)
作为评论的作者那里, TextJustifyUtils.run(textView1,0);
到 TextJustifyUtils .RUN(textView1);
的活动类。但正如我输入无正当理由我的的TextView
即文本的输出是一样的。
In TextJustifyUtils
I change public static void justify(TextView textView)
into public static void run(TextView textView)
as commented by the author there and TextJustifyUtils.run(textView1,0);
into TextJustifyUtils.run(textView1);
in Activity class. But the output is same as I type in my textView
i.e text without justification.
推荐答案
如果有人以下自圆其说文字上面的链接,请选择选项1,它做工精细。如果你有任何问题。请从作者。我觉得他总是乐于帮助你很好的人。当他帮助了我这么多。而选择1正与小的改动。
If some one following the above link to justify text please choose option 1. Its work fine. And if you have any problem. Ask from author. I think he always happy to help you nice guy. As he helps me so much. And option 1 working with minor changes.
这篇关于理由无法正常运行的TextView文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!