我正在参考 TextJustify-Android。我正在上面的链接中实施选项2 。当我在模拟器上运行我的应用时,文本在一行中出现一个单词,在下一行中出现下一个单词,依此类推。我不知道我的代码中有什么问题。请帮我。感谢。
活动类代码 -
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代码 -
<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
课程。
我在TextJustifyUtils.run(textView1);
的链接中进行了一次更改。在我的代码中,eclipse建议我在TextJustifyUtils.run(textView1,0);
中进行更改。这有什么不对吗?
更新
在TextJustifyUtils
我将public static void justify(TextView textView)
更改为public static void run(TextView textView)
,由作者评论,TextJustifyUtils.run(textView1,0);
改为活动类中的TextJustifyUtils.run(textView1);
。但输出与我在textView
中输入的相同,即没有正当理由的文本。
答案 0 :(得分:0)
如果有人按照上述链接来证明文本的合理性,请选择选项1.其工作正常。如果你有任何问题。来自作者的问题。我想他总是很乐意帮助你好人。因为他帮了我很多。选项1可以进行微小的更改。