Code example for Spanned

Methods: subSequence

0
		endOffset = Math.max(0, endOffset);
		endOffset = Math.min(this.text.length() -1, endOffset);
				 
		int start = Math.max(0, endOffset - MAX_PAGE_SIZE);
		 
		CharSequence cutOff = this.text.subSequence(start, endOffset);		
 
		TextPaint textPaint = childView.getPaint();
		int boundedWidth = childView.getWidth();
		StaticLayout layout = new StaticLayout(cutOff, textPaint, boundedWidth , 
				Alignment.ALIGN_NORMAL, 1.0f, bookView.getLineSpacing(), false);
		 
		layout.draw(new Canvas());	
		 
		if ( layout.getHeight() < bookView.getHeight() ) {
			return start;
		} else { 
				 
			int topLine = layout.getLineForVertical( layout.getHeight() - (bookView.getHeight() - 2 * bookView.getVerticalMargin() ) );
			int offset = layout.getLineStart( topLine +2 );
Stop searching for code, let great code find you!  Add Codota to your java IDE