Android TextView获取某一行文字

ViewTreeObserver vto =tvHotTopicDescribe.getViewTreeObserver();

vto.addOnGlobalLayoutListener(newViewTreeObserver.OnGlobalLayoutListener() {

@Override

public voidonGlobalLayout() {

Layout layout =textview.getLayout();

intline ==textview.getLayout().getLineCount();

String result ="";

String text = layout.getText().toString();

for(int i=0;i

int start=layout.getLineStart(i);

int end=layout.getLineEnd(i);

result+=text.substring(start, end)+"\\n";

}

int start=layout.getLineStart(line-1);

int end=layout.getLineEnd(line-1);

result+=text.substring(start, end);

});

你可能感兴趣的:(Android TextView获取某一行文字)