B4A Library LBubble - Bubble labels [Library]

The purpose of the library LBubble, is simply to show bubbles or balloons containing text.
Especially useful for chatting or messaging.

Attention: you need to load the library StringUtils, to use LBubble

LBubble
Author:
Vampirbcn
Version: 2.0

LBubble
Events:
Click ()
-Event that runs when you click on the three dots to expand the content.
Methods:
Initialize (YourActivitymodule As Object, EventName As String)
-Initialize the object
CreateLBubble(parent As Panel, Message As String, messagetop As String, top As Int, width As Int, position As Int) As Int
-Create Label Bubble
LBubbleGradient(ColorInitial As Int, ColorEnd As Int)
-Set gradient colors of bubble background
Properties:
TopTextcolor As Int
-Title text color
Textcolor As Int
-Text color
Textsize As Int
-Text size
TopTextsize As Int
-Title text size
Margin As Int
-Bubble margin with the edge of panel
LBubbleMsgContent As String [read only]
-Full text bubble containing

Image example:
image.png

image2.png


B4X:
'
'
' -----------------------------------------------------------
' --------------  NEEDS StringUtils lib  --------------------
' -----------------------------------------------------------
'
'
'Activity module
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim ScrollView1 As ScrollView
    Dim bubble As LBubble
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim thetop As Int 'bubbles top
    ScrollView1.Initialize(100%y-30) ' scrollview bubble container
    Activity.AddView(ScrollView1,10,10,100%x-20,100%y-30) ' Add Scrollview to activity

    bubble.Initialize(Me,"thebubble") ' initialize LBubble

    ScrollView1.Panel.Width=ScrollView1.Width
    ScrollView1.Panel.Height=ScrollView1.Height

    thetop=20 'assign the top position of the first bubble
    bubble.Textsize=10 ' bubble text size
    bubble.TopTextsize=11 ' bubble title text size
    thetop=bubble.CreatelBubble(ScrollView1.Panel,"Lorem ipsum." & CRLF & "onsectetuer adipiscing elit, sed diam nonummy nibh euismod ...." & CRLF & "Lorem ipsum." & CRLF & "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit" & CRLF & "Lorem itsum dolor.", "01-08-2013", thetop+20, 250, 3)
    thetop=bubble.CreatelBubble(ScrollView1.Panel,"Ok","Message-2", thetop+20, 350, 0)
    thetop=bubble.CreatelBubble(ScrollView1.Panel,"Lorem ipsum." & CRLF & "sed diam nonummy.", "Message-3", thetop+20, 350, 1)

    bubble.TopTextcolor=Colors.Red ' other bubble tittle color
    bubble.Textsize=10 ' other bubble text size
    bubble.TopTextsize=18 ' other bubble text size
    thetop=bubble.CreatelBubble(ScrollView1.Panel,"Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy...." & CRLF & "Lorem ipsum dolor." & CRLF & "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper..." & CRLF & "Lorem ipsum dolor." & CRLF & "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper...." & CRLF & "Loren ipsum." & CRLF & "in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui" & CRLF & "Lorem itsum." & CRLF & "et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilis....", "02-08-2013", thetop+20, 350, 2)


    If thetop>ScrollView1.Panel.Height Then ScrollView1.Panel.Height= thetop+30 ' Reallocate ScrollView1.Panel height
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub thebubble_Click ' bubble click event
     Msgbox(bubble.LBubbleMsgContent,"")
End Sub



-. Sorry for my bad English. -
 

Attachments

  • LBubble.zip
    5.2 KB · Views: 501
Last edited:

shashkiranr

Active Member
Licensed User
Longtime User
Hi Vampirbcn,

Thank you so much for this library :) .

One Kind Request.

1. Can you Please add a method by which we can set the height (BubbleLabel.Height)of each label. This will help to adjust the height based on the text it has.

2. The Bubble Label Click function you mentioned is not working. Kindly give us the right Click Syntax.

3. It would be great if you can add BubbleLabel.Top and BubbleLabel.Height. This would be of great use when setting the inner height of scrollview on which the bubble labels are created.

Regards,
SK
 

billmoultrie

Member
Licensed User
Longtime User
Hi Vampirbcn

I like your library but I could not get thebubble_Click to work, is there an update to your library for this.
I am using your sample program to test.
 
Top