Android Question Cross platform chat layout example, how to change the chat messages height?

dragonguy

Active Member
Licensed User
i try the post Cross platform chat layout example, i facing a problem when i write many words without new line, message cannot show all, also emoji
how can i change the message height to hold all words?
 

Attachments

  • Screenshot_20200226_200440_b4a.example.jpg
    Screenshot_20200226_200440_b4a.example.jpg
    254.9 KB · Views: 74
  • Screenshot_20200226_202440_b4a.example.jpg
    Screenshot_20200226_202440_b4a.example.jpg
    147 KB · Views: 65

dragonguy

Active Member
Licensed User
You are not writing many words, you wrote a single word. Add some spaces between the words and it will wrap.
but we cannot limit end user to must add space to their message.
example like chinese words, when we write chinese word is no need add space,just continue.
 
Upvote 0

lucasheer

Active Member
Licensed User
I'm not sure about the chat example. I have always created my own left/right conversation views, resized them based on the text, and filled up a CustomListView.

My Left/Right views consist of a Panel & Label:
1582792274555.png

1582792253729.png


And then resized them based on the content:
B4X:
Sub CreateLeftContentCard(text As String) As Panel
    Dim p As Panel
    p.Initialize("")
    p.SetLayout(0, 0, 100%x , 60dip)
    p.LoadLayout("messagescontentleft")
    
    lblMessagesContentLeft.Text = text
    lblMessagesContentLeft.Height = su.MeasureMultilineTextHeight(lblMessagesContentLeft, text) + 1dip
    pnlMessagesContentLeft.Height = lblMessagesContentLeft.Height + 25dip
    
    p.Height = pnlMessagesContentLeft.Height + 20dip
    Return p
End Sub

Result:
Capture.JPG


For the textbox, I hook onto TextChanged and calculate/change the height of the panels accordingly.
 
Upvote 0
Top