One, on Android, a single textview is not scrollable and needs to be placed in a scrollview. ScrollView provides a series of functions where Fullscroll is used to implement FOCUS_UP and Focus_down keys, that is, scrolling to the top and bottom. If you call Fullscroll immediately after TextView append, you'll find that you can't scroll to the bottom, because many of the functions on Android are message-based and Message Queuing guarantees synchronization, so function calls are mostly asynchronous operations. Message Queuing is asynchronous, Message Queuing scrolls to the bottom and then TextView's Append method is displayed. So I can't scroll to the bottom correctly. Solutions:final scrollview scrollview = (ScrollView) Findviewbyid (r.id.scrollview1); if (scrollview != null) { scrollview.post (new runnable () { public void run () { scrollview.fullscroll (Scrollview.focus_down); } }); the ListView is used with the scrollbar to prevent the ListView from scrolling, Use the scroll bar to scroll to the bottom of the ListView to change the sentence in the above code run to this Scrollview.scrollto (0, mlistviewlist.getheight ()); three, ListView Internal Height Calculation function when the ListView is used with the vertical scroll bar, use only external scrollview instead of the ListView scroll. The following function is required to calculate the current height of the ListView. Public static void recallistviewheightbasedonchildren (Listview listview) { if (listview == null) return; listadapter listadapter = listview.getadapter (); if (listadapter == null) return; int nTotalHeight = 0; for (Int i = 0; i < listadapter.getcount (); i++) { view&nbSp;listitem = listadapter.getview (I, null, listview); listitem.measure (0, 0); ntotalheight += listitem.getmeasuredheight (); } viewgroup.layoutparams params = listview.getlayoutparams (); params.height = nTotalHeight + (Listview.getdividerheight () * ( Listadapter.getcount ()-1));}
PS: For APP security detection Generally I will use:www.ineice.com
Elementary Introduction: The Append method of Android TextView is used in conjunction with scroll bar