Richten Sie Text in der Textansicht so aus, dass er nicht richtig funktioniert
Ich beziehe mich aufTextJustify-Android. Ich setze umOption 2 im obigen Link. Wenn ich meine App auf einem Emulator-Text ausführe, erscheint ein Wort in einer Zeile, das nächste Wort in der nächsten Zeile und so weiter. Ich weiß nicht, was in meinem Code falsch ist. Bitte hilf mir. Vielen Dank.
Aktivitätsklassencode-
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>
Und ich setze umTextJustifyUtils
Klasse in meiner App, wie im obigen Link vorgeschlagen.
Ich habe in diesem Link eine Änderung vorgenommenTextJustifyUtils.run(textView1);
und In meinem Code schlagen Eclipse vor, mich zu ändernTextJustifyUtils.run(textView1,0);
. Stimmt etwas damit nicht?
Aktualisieren:
ImTextJustifyUtils
Ich änderepublic static void justify(TextView textView)
inpublic static void run(TextView textView)
wie vom Autor dort kommentiert undTextJustifyUtils.run(textView1,0);
inTextJustifyUtils.run(textView1);
in der Aktivitätsklasse. Aber die Ausgabe ist die gleiche wie bei meiner EingabetextView
d.h. Text ohne Begründung.