The horizontal scroll problem

I am relatively new to Android. I am working on an application in which I want to display digital signals. But the problem is that I occupy the available screen width, how to add a scroll function to continue viewing the signal. I also draw a signal using drawLine (), so what coordinates should I set to draw lines when scrolling is on? Someone please give a simple example where the line extends more than the available screen width and you can scroll to see the rest of the line. Thanx in advance.

+3
source share
1 answer

I wrote several of them earlier in other languages, so I can introduce you to principles, not an example. I assume that you have some buttons on the left and right that allow the user to scroll through the data and that your signal data is stored in an array. You can determine how much data you can fit into one screen width, based on any scaling factor you use. Suppose you can display ten values ​​at a time on your screen, then you just save the starting point in your signal array and use this at most to display on the screen. Then all you have to do is show the following ten values ​​in your array. When the user selects a button to move left or right through the data, simply increase or decrease the starting point.If you broadcast your signal, the stream may increase the starting point when you receive a new piece of data. When you redraw after each change in the initial value, you get the impression of a scroll. Keep track of the start and end conditions (i.e. you don't want to scroll until you have at least a full data screen). All you do is create a window on the data that you have.

, .

0

Source: https://habr.com/ru/post/1731173/


All Articles