当前位置: 代码迷 >> Android >> Android ScollView挪动到最底端
  详细解决方案

Android ScollView挪动到最底端

热度:25   发布时间:2016-05-01 11:14:33.0
Android ScollView移动到最底端

有两种方式:

第一种:chatScroll为scollView控件对象

chatScroll.post(new Runnable() {     public void run() {         chatScroll.fullScroll(ScrollView.FOCUS_DOWN);     } }); 

第二种:

/*** 将ScollView 移动到最底端* @param scroll ScollView	* @param inner ScollView里面一层控件的View* @param moreHeight 多余的高度*/public static void scrollToBottom(final View scroll, final View inner ,final int moreHeight) {	Handler mHandler = new Handler();	mHandler.post(new Runnable() {		public void run() {			if (scroll == null || inner == null) {				return;			}			int offset = inner.getMeasuredHeight() - scroll.getHeight()					+ moreHeight;			if (offset < 0) {				offset = 0;			}			scroll.scrollTo(0, offset);		}	});}






  相关解决方案