赞
踩
非原创 原创地址
https://www.cnblogs.com/snser/p/5159125.html
该文主要留着之际以后遇到 不用再次百度找答案
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
textView = (TextView)findViewById(R.id.text);
textView.setText(url);
// 解决呗强制换行问题
textView.getViewTreeObserver().addOnGlobalLayoutListener(new OnTvGlobalLayoutListener());
private String autoSplitText(final TextView tv) {
final String rawText = tv.getText().toString(); //原始文本
final Paint tvPaint = tv.getPaint(); //paint,包含字体等信息
final float tvWidth = tv.getWidth() - tv.getPaddingLeft() - tv.getPaddingRight(); //控件可用宽度
//将原始文本按行拆分
String [] rawTextLines = rawText.replaceAll("\r", "").split("\n");
StringBuilder sbNewText = new StringBuilder();
for (String rawTextLine : rawTextLines) {
if (tv
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。