Android Question Max height of panel with canvas in scrollview

MartinR

Member
Licensed User
I am trying to display some rows of information. Each row has a row number followed by numbers, e.g.

...
123 4 5 6 7 8 1 2 3
124 4 6 5 8 7 2 1 3
...

There could be up to 6000 rows and I want to be able to scroll up and down.
I've implemented this in VB6 using a fixed picture and drawing just 30 rows to the picture at a time, with a vertical scrollbar controlling which 30 rows are displayed.

I thought I would be able to draw all 6000 rows to a canvas on a scrollview panel of the requisite height, and just scroll the view up and down, but I seem to be limited to 100 or 200 rows.

I don't get any error messages when trying, say, a 300-row data set, but get nothing displayed apart from a dark grey scrollview with a little indicator on the right hand side of the screen sliding up and down.

The following code illustrates the issue:

Sub Globals
Dim scv1 As ScrollView
Dim cvs1 As Canvas
End Sub

Sub Activity_Create(FirstTime As Boolean)
scv1.Initialize(0)
Activity.AddView(scv1,0,0,100%x,100%y)
scv1.Panel.Width=scv1.Width
scv1.Panel.Height=scv1.Height * 7 'OK with * 6
Dim panelcolor As ColorDrawable
panelcolor.Initialize(Colors.RGB(255,255,192),10)
scv1.Panel.Background=panelcolor
cvs1.Initialize(scv1.Panel)
Dim row As Int
For row = 1 To 2000
cvs1.DrawText(row,0,row * 20,Typeface.DEFAULT,12,Colors.Red,"LEFT")
Next
scv1.Panel.Invalidate
scv1.Invalidate
Activity.Invalidate
End Sub

If I make the scrollview panel 6 times the screen height this works OK, but get a blank display for 7 times.

B4A 5.8. Target is BLU ENERGY DIAMOND phone, Android 6
 

ronell

Well-Known Member
Licensed User
Longtime User
CODETAGS.png
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Is there a specific reason why you're drawing the text manually onto the panel's canvas rather than just adding labels containing your text?
 
Upvote 0

MartinR

Member
Licensed User
Is there a specific reason why you're drawing the text manually onto the panel's canvas rather than just adding labels containing your text?
Yes, I should have explained...
The horizontal positioning of each digit corresponds to some timing associated with that digit and needs the drawtext facility for this. Also, I will want to draw lines through the paths of each digit from one row to the next, together with small, carefully positioned coloured rectangles.

The background to this is bell-ringing, and the app is to highlight errors in the rhythm (striking) of each ringer.

Apologies for pasting the code as text rather than using the correct facility.

Martin
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Creating bitmaps this large can be problematic, especially if you haven't locked the device to one specific orientation and your users tips the phone back-and-forth repeatedly (you'll run out of memory fairly quickly).

I would suggest you see if you can construct your layout using the standard label controls (remember, you can make a "line" by having a blank label and setting its background color and position/size).
 
Upvote 0

MartinR

Member
Licensed User
The kind of display I am trying to create is like the attached screenshot from the VB6 version.

Following your replies I am reassured that I am not doing anything wrong in terms of code, but am facing memory limitations.

I will take the approach of creating and displaying a relatively small bitmap representing just a few (30 or so) rows of ringing in response to a seekbar event and effectively scroll through the available striking data that way.

Many thanks for your help.
 

Attachments

  • ranneys.gif
    ranneys.gif
    101.9 KB · Views: 375
Upvote 0

MartinR

Member
Licensed User
Am I right: seekbars only work horizontally!? I want to scroll the display up and down so would like vertical action.
Perhaps some code involving _touch event on a designated panel?
 
Upvote 0
Top