I am relatively new to Android. I am working on an application wherein i want to display digital signals. But the problem is once I occupy the available screen width how to i add a scrolling feature to continue viewing the signal. Also i am drawing the signal using using drawLine(), so what co-ordinates should i set for drawing the lines when scrolling is enabled? Can somebody please give a simple example where a line extends more than the available screen width and you 开发者_运维百科can scroll through to see the remaining line. Thanx in advance.
I've written a few of these before in other languages, so I can ive you the principles, rather than an example. I'm assuming you have some sort of buttons to the left and right that allows the user to scroll through the data, and that your signal data is stored in an array. You will be able to determine how much data you can fit into one screen width based on whatever scaling factor you are using. Say your screen can display ten values at a time, then you simple store the starting point in your signal array and use that as the left most point to display on your screen. Then all you have to do is show the next ten values in your array. When the user selects the button to move left or right through the data simply increment or decrement the starting point. If you are streaming in your signal, then the stream can increment the starting point whenever you receive a new piece of data. A redraw after each start value change will give the impression of scrolling. Watch out for start and end conditions (i.e. you don't want to scroll until you have at least a full screen of data). All you are doing is creating a window onto the data you have.
Hope this helps.
精彩评论