【发布时间】:2014-02-07 18:24:24
【问题描述】:
我正在参考 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); Activity 类。但输出与我在textView 中输入的相同,即没有理由的文本。
【问题讨论】:
-
但是为什么要删除这个问题你知道任何其他方式来证明使用 textview 而不是 webview。
-
好的那怎么办?