diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml
index f00d4c185..7018958cf 100644
--- a/common/src/main/res/values/strings.xml
+++ b/common/src/main/res/values/strings.xml
@@ -381,7 +381,7 @@
has followed the anchor
Are you sure to report?
Interaction
- Quit even wheat
+ End mic
Allowed even wheat
Ban Lian Mai
Initiate a link request
diff --git a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
index 81bf31316..00e0252d0 100644
--- a/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
+++ b/live/src/main/java/com/yunbao/live/utils/LiveTextRender.java
@@ -949,6 +949,8 @@ public class LiveTextRender {
// availableWidth textView 可用宽度 prefixWidth 图片宽度
int availableWidth = textView.getWidth() - textView.getPaddingLeft() - textView.getPaddingRight();
// Log.e("renderChatNew", "availableWidth: " + availableWidth);
+// Log.e("renderChatNew", "textView.getPaddingLeft(): " + textView.getPaddingLeft());
+// Log.e("renderChatNew", "textView.getPaddingRight(): " + textView.getPaddingRight());
StringBuilder sb = new StringBuilder();
String name = bean.getUserNiceName();
@@ -966,22 +968,25 @@ public class LiveTextRender {
if (nameWidth + prefixWidth > availableWidth) {
StringBuilder sb_tmp = new StringBuilder();
+ StringBuilder saveContentSB = new StringBuilder();
int initImageWidth = prefixWidth;
for (int i = 0; i < sb.length(); i++) {
char content = sb.charAt(i);
sb_tmp.append(content);
- float measuredText = paint.measureText(sb_tmp.toString()) + initImageWidth;
-// Log.e("renderChatNew", "measuredText: " + measuredText + " availableWidth: " + availableWidth);
- if (measuredText > availableWidth) {
+ float measuredTextWidth = paint.measureText(sb_tmp.toString()) + initImageWidth;
+// Log.e("renderChatNew", "文字:" + sb_tmp.toString() + " measuredTextWidth: " + measuredTextWidth + " initImageWidth:" + initImageWidth + " availableWidth: " + availableWidth);
+ if (measuredTextWidth > availableWidth) {
initImageWidth = 0;
- sb_tmp.deleteCharAt(sb_tmp.length() - 1);
- sb_tmp.append("\n");
- sb_tmp.append(content);
+ saveContentSB.append("\n");
// Log.e("renderChatNew", "sb_tmp.toString():" + sb_tmp.toString());
+ sb_tmp.setLength(0);
+ sb_tmp.append(content);
}
+ saveContentSB.append(content);
+// Log.e("renderChatNew", "saveContentSB.toString():" + saveContentSB.toString());
}
- builder.append(sb_tmp);
+ builder.append(saveContentSB);
// Log.e("renderChatNew", "builder.toString():" + builder.toString());
} else {
@@ -1030,25 +1035,25 @@ public class LiveTextRender {
}
SpannableStringBuilder sb = new SpannableStringBuilder();
sb.append(name);
- float measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
+ float measuredTextWidth = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
// Rect mRect = new Rect();
// textView.getPaint().getTextBounds(sb.toString(), 0, sb.length(), mRect);
int width = (int) (((ViewGroup) textView.getParent()).getMeasuredWidth() - prefixEmpty);
String TAG = "文字渲染";
- // Log.i(TAG, "测算|" + measuredText + "|" + mRect.width() + "|" + sb.toString());
+ // Log.i(TAG, "测算|" + measuredTextWidth + "|" + mRect.width() + "|" + sb.toString());
//|810|810|810|786|786
// Log.i(TAG, "控件宽度|" + width + "|" + ((ViewGroup) textView.getParent()).getWidth() + "|" + ((ViewGroup) textView.getParent()).getMeasuredWidth() + "|" + textView.getWidth() + "|" + textView.getMeasuredWidth());
// Log.i(TAG, "前缀预留宽度|" + prefixWidth + "|" + prefixEmpty);
// Log.i(TAG, "renderChat: " + textView.getCompoundPaddingLeft() + "|" + textView.getCompoundPaddingRight() + "|");
//检测渲染后图标+名字是否超过父布局宽度,超过了就做换行处理
String prefixName = "";
- if (measuredText > width) {
+ if (measuredTextWidth > width) {
sb.clear();
for (int i = 0; i < name.length(); i++) {
sb.append(name.charAt(i));
- measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
- Log.i(TAG, i + "逐测算|" + measuredText + "|" + textTemp);
- if (measuredText > width) {
+ measuredTextWidth = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
+ Log.i(TAG, i + "逐测算|" + measuredTextWidth + "|" + textTemp);
+ if (measuredTextWidth > width) {
prefixName = name.substring(0, i + textTemp);
name = prefixName + "\n" + name.substring(i + textTemp);
break;
@@ -1079,12 +1084,12 @@ public class LiveTextRender {
Log.i(TAG, "renderChat: " + content);
sb.append(name).append(content);
SpannableStringBuilder csb = null;
- measuredText = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
+ measuredTextWidth = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
sb.clear();
sb.append(prefixName);
prefixEmpty = textView.getPaint().measureText(sb, 0, sb.length()) + prefixWidth;
StringBuilder stringBuilder = new StringBuilder();
- if (measuredText > width) {
+ if (measuredTextWidth > width) {
sb.clear();
sb.append(name);
float lineWidth = 0;