I would like to display a paragraph of long text as follow. Here is the snapshot from Flipboard.
Try this.
Layout XML
Activity class
public class MainActivity extends Activity {
private String inputString = "op British supermarket Tesco (LSE: TSCO) (NASDAQOTH: TSCDY.US) is due to announce its half year results on and this is the extra bit of spill text";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView bigChar = (TextView) findViewById(R.id.bigChar);
final TextView sideText = (TextView) findViewById(R.id.sideText);
final TextView spillText = (TextView) findViewById(R.id.spillText);
ViewTreeObserver vto = sideText.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Layout layout = sideText.getLayout();
int numOfLines = layout.getLineEnd(2);
// split the string now
String spillTextString = inputString.substring(numOfLines, inputString.length());
spillText.setText(spillTextString);
}
});
}
}