【问题标题】:justify text in textview not working properly证明 textview 中的文本无法正常工作
【发布时间】: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。
  • 好的那怎么办?

标签: android github textview


【解决方案1】:

如果有人按照上述链接证明文本,请选择选项 1。它工作正常。如果你有任何问题。向作者提问。我想他总是很乐意帮助你的好人。因为他对我帮助很大。选项 1 进行了细微的更改。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-02
    • 1970-01-01
    • 2015-12-13
    • 1970-01-01
    相关资源
    最近更新 更多