mirror of
https://github.com/KokaKiwi/BarInsta
synced 2026-03-15 00:41:35 +00:00
Include textview left padding while calculating last line width in text messages. For austinhuang0131/barinsta#1222
This commit is contained in:
parent
3b41cd78bd
commit
79fe697167
3 changed files with 30 additions and 4 deletions
|
|
@ -105,12 +105,15 @@ public class ChatMessageLayout extends FrameLayout {
|
|||
viewPartMainLastLineWidth = viewPartMainLineCount > 0
|
||||
? ((TextView) firstChild).getLayout().getLineWidth(viewPartMainLineCount - 1)
|
||||
: 0;
|
||||
// also include start left padding
|
||||
viewPartMainLastLineWidth += firstChild.getPaddingLeft();
|
||||
}
|
||||
|
||||
if (viewPartMainLineCount > 1 && !(viewPartMainLastLineWidth + viewPartInfoWidth > viewPartMain.getMeasuredWidth())) {
|
||||
final float lastLineWithInfoWidth = viewPartMainLastLineWidth + viewPartInfoWidth;
|
||||
if (viewPartMainLineCount > 1 && lastLineWithInfoWidth <= viewPartMain.getMeasuredWidth()) {
|
||||
widthSize += viewPartMainWidth;
|
||||
heightSize += viewPartMainHeight;
|
||||
} else if (viewPartMainLineCount > 1 && (viewPartMainLastLineWidth + viewPartInfoWidth > availableWidth)) {
|
||||
} else if (viewPartMainLineCount > 1 && (lastLineWithInfoWidth > availableWidth)) {
|
||||
widthSize += viewPartMainWidth;
|
||||
heightSize += viewPartMainHeight + viewPartInfoHeight;
|
||||
} else if (viewPartMainLineCount == 1 && (viewPartMainWidth + viewPartInfoWidth > availableWidth)) {
|
||||
|
|
@ -120,6 +123,16 @@ public class ChatMessageLayout extends FrameLayout {
|
|||
heightSize += viewPartMainHeight;
|
||||
widthSize += viewPartMainWidth + viewPartInfoWidth;
|
||||
}
|
||||
|
||||
// if (isInEditMode()) {
|
||||
// TextView wDebugView = (TextView) ((ViewGroup) this.getParent()).findViewWithTag("debug");
|
||||
// wDebugView.setText(lastLineWithInfoWidth
|
||||
// + "\n" + availableWidth
|
||||
// + "\n" + viewPartMain.getMeasuredWidth()
|
||||
// + "\n" + (lastLineWithInfoWidth <= viewPartMain.getMeasuredWidth())
|
||||
// + "\n" + (lastLineWithInfoWidth > availableWidth)
|
||||
// + "\n" + (viewPartMainWidth + viewPartInfoWidth > availableWidth));
|
||||
// }
|
||||
}
|
||||
setMeasuredDimension(widthSize, heightSize);
|
||||
super.onMeasure(MeasureSpec.makeMeasureSpec(widthSize, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(heightSize, MeasureSpec.EXACTLY));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue