2

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 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-

 <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>

And I am implementing TextJustifyUtils class in my app as suggested in above link.

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?

Update:

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.

John R
  • 2,078
  • 8
  • 35
  • 58

1 Answers1

0

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.

John R
  • 2,078
  • 8
  • 35
  • 58