Android Question B4XView to contain text with scrolling


Active Member
Licensed User
Longtime User
I have a reasonably sizeable amount of text which I want to display. I want scrolling (ideally both vertical & horizontal, but at least vertical) so that if it's bigger than the space allocated in the Designer the user would be able to see all the text using scrolling.
As I'm using B4XPages, I would like any views to be defined as B4XView.
The current Label that I have containing the text is defined as 'Private lblMe As B4XView' with it 'shown' in the Designer layout, and I have a ScrollVew defined as 'Private scvMe As B4XlView. I'm using the StringUtils library. The following code is in B4XMainPage as 'Private Sub B4XPage_Created'.

scvMe.AddView(lblMe, _
                  0, _
                  0, _
                  scvMe.ScrollViewContentWidth, _
    Dim MeText As String
    MeText = "I am an artist and printmaker who specialises in pet portraits. " & CRLF & _
             "So I can produce a beautiful painting of your furry friend(s) for a very reasonable price. " & CRLF & _
             "I also accept commissions to do pictures of landscapes and buildings. " & CRLF & CRLF & _
             "I also design and deliver in person painting courses. " & CRLF & _
             "The steps of a painting course entitled 'Acrylic Painting using Painting Knives' are shown below." & CRLF & _
             "My web site is"                                                       
    lblMe.Text = MeText
    Dim ht As Float
    ht = StrUtil.MeasureMultilineTextHeight(lblMe, MeText)
    scvMe.ScrollViewContentHeight = ht
    lblMe.Height = ht
    scvMe.ScrollViewOffsetY = 0

I feel that the above concept & coding is wrong. What should I change?


Licensed User
Longtime User
I would use WebView and load the html code locally, instead of a regular label to display that text.

You will have a lot of control on formatting the text and by using Webview, you could configure it so that your http link will actually open an external browser when the user clicks on it.
Upvote 0