make a TextView scrollable + Bug in Android -
i have read post: making textview scrollable on android without success.
my app looks this:
where black space textview. declared @ xml this:
<textview android:id="@+id/consola" android:layout_width="320px" android:layout_height="333px" android:layout_alignparenttop="true" android:layout_alignparentleft="true" android:scrollbars = "vertical" android:gravity="top|left" android:inputtype="textmultiline" > </textview>
and code takes text edittext when button pressed, , writes new line @ textview text. code looks like:
public class helloworldactivity extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); final textview miconsola = (textview) findviewbyid(r.id.consola); miconsola.setmovementmethod(new scrollingmovementmethod()); final edittext lineacomando = (edittext) findviewbyid(r.id.linea_comando); final button botonconectar = (button) findviewbyid(r.id.boton_conectar); final button botonenviar = (button) findviewbyid(r.id.boton_enviar); botonenviar.setenabled(false); botonconectar.setonclicklistener(new onclicklistener() { public void onclick(view v) { // intentaremos conectar por bluetooth aqui botonconectar.setenabled(false); botonenviar.setenabled(true); } }); botonenviar.setonclicklistener(new onclicklistener() { public void onclick(view v) { // enviamos el comando charsequence comando = lineacomando.gettext(); miconsola.append(comando+"\r\n"); } }); miconsola.append("esto es una prueba\r\n"); miconsola.append("esto es otra prueba\r\n"); }
}
but when text reaches bottom of textview, still writes new line on edittext, , if go on, no scroll bar appear.
any idea of i'm doing wrong?
put text view in vertical scrollview.set height of scroll view fixed height did text view.then set wrap_content text view's width , height.
Comments
Post a Comment