justificar texto no textview não está funcionando corretamente
Estou tomando referência deTextJustify-Android. Estou implementandoopção 2 no link acima. Quando executo meu aplicativo no emulador, o texto aparece uma palavra em uma linha, a próxima palavra na próxima linha e assim por diante. Não sei o que há de errado no meu código. Por favor me ajude. Obrigado.
Código da classe de atividade
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;
}
});
Código 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>
E estou implementandoTextJustifyUtils
classe no meu aplicativo, conforme sugerido no link acima.
Eu fiz uma mudança nesse link dadoTextJustifyUtils.run(textView1);
e No meu código eclipse, sugiro que eu mudeTextJustifyUtils.run(textView1,0);
. Há algo de errado nisso?
Atualizar:
NoTextJustifyUtils
eu mudopublic static void justify(TextView textView)
para dentropublic static void run(TextView textView)
como comentado pelo autor lá eTextJustifyUtils.run(textView1,0);
para dentroTextJustifyUtils.run(textView1);
na classe Activity. Mas a saída é a mesma que digito no meutextView
ou seja, texto sem justificativa.