Dim ivText As B4XView = CreateImageView
'get the bitmap from BBCodeView1 foreground layer.
Dim bmpText As B4XBitmap = GetBitmap(BBCodeView1.ForegroundImageView)
'the image might be scaled by Engine.mScale. The "correct" dimensions are:
Dim TextWidth As Int = bmpText.Width / Engine.mScale
Dim TextHeight As Int = bmpText.Height / Engine.mScale
'bc is not really used here. Only the utility method.
bc.SetBitmapToImageView(bmpText, ivText)
Dim ivBG As B4XView = CreateImageView
'Draw the bubble.
Dim bmpBG As B4XBitmap = DrawBubble(TextWidth, TextHeight, Right)
bc.SetBitmapToImageView(bmpBG, ivBG)
p.SetLayoutAnimated(0, 0, 0, CLV.sv.ScrollViewContentWidth - 2dip, TextHeight + 3 * Gap)
'2020-01-16 16:54:29
DateTime.DateFormat = "yyyy-MM-dd HH:mm:ss"
If Right Then
p.AddView(ivBG, p.Width - bmpBG.Width * xui.Scale, Gap, bmpBG.Width * xui.Scale, bmpBG.Height * xui.Scale) 'BALÃO
p.AddView(ivText, p.Width - Gap - ArrowWidth - TextWidth, 2 * Gap, TextWidth, TextHeight) 'TEXTO
...