Code example for ScrollView

Methods: getHeight, getScrollY, post

0
		String line = (String)msg.obj;
		 
		checkForError(line);
		 
		final boolean autoscroll = 
		  (mScrollView.getScrollY() + mScrollView.getHeight() >= mLines.getBottom()) ? true : false;
			 
		TextView lineView = new TextView(LogcatActivity.this);
		lineView.setTypeface(Typeface.MONOSPACE);
		lineView.setText(new LoglineFormattedString(line));
 
		mContext.addLine(line);
		mLines.addView(lineView, new LayoutParams(LayoutParams.FILL_PARENT,
		  LayoutParams.WRAP_CONTENT));
 
		if (mLines.getChildCount() > MAX_LINES)
			mLines.removeViewAt(0);
 
		/* Lame trick so our code runs after mLines#onMeasure.  Ideally we 
		 * should use a custom widget here. */ 
		mScrollView.post(new Runnable() {
			public void run() 
			{ 
				if (autoscroll == true)
				{ 
					mScrollView.scrollTo(0,