SK9*_*SK9 10 android text textview
我有一个TextView,其文本可以运行到很多行.一旦它被动态创建和设置,我想
我该怎么做呢?
CjS*_*CjS 21
如果我理解正确,问题2的答案是:
textView.getLineBounds (int line, Rect bounds)
Run Code Online (Sandbox Code Playgroud)
像素的宽度应该是abs(bounds.right - bounds.left); 而且高度是abs(bounds.bottom - bounds.top)
你的第一个问题有点棘手,但这样的事情应该做所需的魔术:
Layout layout = textView.getLayout();
String text = textView.getText().toString();
int start=0;
int end;
for (int i=0; i<textView.getLineCount(); i++) {
end = layout.getLineEnd(i);
line[i] = text.substring(start,end);
start = end;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7837 次 |
| 最近记录: |