how to make horizontal scrollview extra wide

Jondroid

Member
Licensed User
Longtime User
I have a need for an extremely wide horizontal scrollview. As I understand I have to add views to the panel property of HorizontalScrollview. So far so good, but I want a very wide panel, in fact as wide as possible. However, I have issues making the panel much wider than something in the order of 16000. The help says that I should be INT.

So my question is, how to make a horzitonalscrollview wider than about 16000 pixels?

I understand that most people might think that 16000 should be enough for all sorts of problems but in my case I really need an extremely wide panel and it should be scrollable.

Any help would be greatly appreciated.
Jon
 
Last edited:

Jondroid

Member
Licensed User
Longtime User
Hi Erel,
I get a "force close".

Attached is the minimal version which demonstrates the problem.

B4X:
   Activity.LoadLayout("main")
      HorizontalScrollView1.panel.Width=20000 '<----changing this to 15000 will solve the issue
      HorizontalScrollView1.panel.Height=405
      HorizontalScrollView1.panel.Initialize("")
      
      cvs.Initialize(HorizontalScrollView1.Panel)
 

Attachments

  • test-panel-width.zip
    6.1 KB · Views: 342
Upvote 0

Jondroid

Member
Licensed User
Longtime User
Very interesting! Thanks for the hint how to debug "force close"-ing apps. Of course the question arises how to work around this problem?
 
Upvote 0

Jondroid

Member
Licensed User
Longtime User
As of my previous posts, I'm working on an oscilloscope. Currently I'm exploring the possibilities of developing a logic analyzer mode (like buspirate thing). And there you need to be able to scroll through all the transient data.

So, the short answer is: unfortunately yes, i do need to draw over all the panel.

Otherwise I will only have something like about 15000 samples to see (which is actually fairly low for a logic analyser, they ususally have the ability to monitor and plot millions of samples.)
 
Upvote 0

Jondroid

Member
Licensed User
Longtime User
I've just been trying to find another work around using:

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim HorizontalScrollView1 As HorizontalScrollView
   Dim panel1 As Panel
   Dim panel2 As Panel
   Dim cvs1 As Canvas
   Dim cvs2 As Canvas
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then 
      Activity.LoadLayout("main") ' also doesn't work ...
      HorizontalScrollView1.panel.Width=200000
      HorizontalScrollView1.panel.Height=405
      HorizontalScrollView1.panel.Initialize("")
      
      panel1.Initialize("")
      HorizontalScrollView1.Panel.AddView(panel1,0,0,15000,405)
      cvs1.Initialize(panel1)
      
      panel2.Initialize("")
      HorizontalScrollView1.Panel.AddView(panel2,15000,0,5000,405)
      cvs2.Initialize(panel2)
   End If
End Sub

This is actually quite interesting as in fact I can have a 200 000 px wide horizontalscrollview, which is indeed nice. I thought that by having now two canvases in the scrollview we might not get the error. Still, I get the "force close".
So the above also doesn't work. But it demonstrates that I'm very happy to find a workaround so that I can in fact make use of a very wide horizontal scrollview.
 
Upvote 0

Jondroid

Member
Licensed User
Longtime User
Erel,
according to your suggestion I tried the following:

B4X:
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim HorizontalScrollView1 As HorizontalScrollView
   Dim panel1 As Panel
   Dim panel2 As Panel
   Dim cvs1 As Canvas
   Dim cvs2 As Canvas
   Dim Bitmap As Bitmap
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then 
      Activity.LoadLayout("main") ' also doesn't work ...
      HorizontalScrollView1.panel.Width=200000
      HorizontalScrollView1.panel.Height=405
      HorizontalScrollView1.panel.Initialize("")
      
      Bitmap.InitializeMutable(30000,405)
      cvs1.Initialize2(Bitmap)
   
   End If
End Sub

But this also fails.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
I think you need to define a bit more what you want to do and understand where the limitations lie.
As far as I remember the maximum memory allocated to an android program was 16 MB (or maybe 24 MB) or maybe it has changed now (depending on the API Level you are targeting).
To be safe your bitmap needs to be smaller than 16 MB.
This will be calculated by: Width x Height x BitsPerPixel
BitsPerPixel will come from the required color depth (I dont know which ones B4A supports)
Another thing to consider is the granularity of the captured signal. (which determines the height of the bitmap).

Also depends on how 'real-time' you want the capture and display to be.
You could be capturing the data separately and writing out to a bitmap file, while the display portion loads the bitmap a few screens at a time (maybe 3x screen width)
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I agree with thedesolatesoul, you must explain much more in detail:
- what data do you have ?
- where it does come from ?
- at what sampling rate ?
- or is it static after acqusition ?
- what update rate do you want (need) ?
etc. etc.

I know, a lot of questions, but without answers to these, it's difficult to give you a concrete answer.

There are probably several solutions to your problem, but without more information we can't give you a good one.

A very big bitmap is NOT a solution, beacause of memory problems.

You nedd to use a smaller bitmap and update it by drawing the next or previous data part depending on the 'scrolling'.

Best regards.
 
Upvote 0

Jondroid

Member
Licensed User
Longtime User
Thank you for the feedback. I'm very new to android developing and I was thinking of building a logic analyzer like the bus pirate or openworkbench. I don't have the full specifications myself yet (e.g. how to get the data into the mobile phone or if it needs to be realtime or not). So I may use the usb-host functionality of the phone and probably a serial converter which gets the data from the microcomputer collecting/sampling the data.
Ususally the sampling rates are very high (e.g. 200 Megasamples per second). So, I'm afraid, I won't be able to provide clear specifications as to what exactly I need. Initially I just thought that the horziontalScrollview will solve all my problems. But the last few posts make it clear that I probably need to invent my own kind of control (probably as suggested with caching a few screens to each side and replacing them.)

So I will try to play around with this in the next couple of days.

One thing which I found rather interesting (and I'm glad that I asked the question even though it sounded a bit dumb) is the pointer to colour depths. This makes really good sense to me and just plotting a few lines doesn't require that I have 24bit. I guess four colours would be more than enough.

So to narrow down my question for the moment: does anyone can tell me how I can change the colour depth of a mutuable bitmap or canvas?

Many thanks for your patience and your help.
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
However, one thing i just realized is that you do not need a bitmap.
Considering, you will plot one 'x' per 'y' , you are effectively leaving more than 99% of the bitmap empty. Not only is that a waste of memory and storage, it is also a waste of bandwidth and efficiency.
It will actually be faster just to save one value per sample instead of the whole bitmap.


Sent from my GT-I9000 using Tapatalk
 
Upvote 0
Top