Home > Mobile >  Android View how to draw while moving left?
Android View how to draw while moving left?

Time:10-09

In the most the right side of the phone's screen draw a vertical bar, push the front have moved to draw good vertical bar to the left, and
I keep seeing effect as in the most the right side of the phone's screen whole vertical bar, pushing the front has good vertical bar a little bit left, eventually paved with mobile phone screen,

How to promote the front draw good vertical bar lines left to move?

CodePudding user response:

Draw the figure in advance, and then the transaction animation movement from right to left

CodePudding user response:

reference m - 1/f, oj response:
draw this figure in advance, and then the transaction had animated movement from right to left


No,
This is dynamic, like electrocardiogram (ecg), the right of drawing the latest line, on the left side of the line in turn left,

CodePudding user response:

refer to the second floor eddysong9280 response:
Quote: reference m - 1/f, oj response:

Draw the figure in advance, and then the transaction had animated movement from right to left


No,
This is dynamic, like electrocardiogram (ecg), the right of drawing the latest line, on the left side of the line in turn left,

That can be drawn with surfaceview, first set a line properties (length, width), according to the width of the view to define the array length, define a refresh time like 50 ms, once every 50 ms redrawn, each time the data can be mapped in the array

CodePudding user response:

reference 3/f m - oj response:
Quote: refer to the second floor eddysong9280 response:

Quote: reference m - 1/f, oj response:

Draw the figure in advance, and then the transaction had animated movement from right to left


No,
This is dynamic, like electrocardiogram (ecg), the right of drawing the latest line, on the left side of the line in turn left,

That can be drawn with surfaceview, first set a line properties (length, width), according to the width of the view to define the array length, define a refresh time like 50 ms, once every 50 ms redrawn, each time the data can be mapped in the array


When is the latest vertical lines, vertical lines on the screen in front of how to realize the shift to the left? Remove the inside of the array data left a pixel in every line and then painted all the line? Efficiency is too low?

CodePudding user response:

Eddysong9280
reference 4 floor response:
Quote: reference 3/f m - oj response:

Quote: refer to the second floor eddysong9280 response:

Quote: reference m - 1/f, oj response:

Draw the figure in advance, and then the transaction had animated movement from right to left


No,
This is dynamic, like electrocardiogram (ecg), the right of drawing the latest line, on the left side of the line in turn left,

That can be drawn with surfaceview, first set a line properties (length, width), according to the width of the view to define the array length, define a refresh time like 50 ms, once every 50 ms redrawn, each time the data can be mapped in the array


When is the latest vertical lines, vertical lines on the screen in front of how to realize the shift to the left? Remove the inside of the array data left a pixel in every line and then painted all the line? Efficiency is too low?

Make good use of data structure, queue,,

CodePudding user response:

The overall effect is when a new vertical lines to draw on the most the right side of the screen, at the same time, all previous is good vertical lines turn left a pixel,
Look at is the most the right side of the screen the latest vertical bar (vertical bar width is 1 pixel), pushes the vertical bar in front of a little left, right into the line, on the left side of the screen,

Is now in the timer walk the following procedures: pointX=screen width (assuming=1080), the drawPoint always drawn in most the right side of the screen, left a finished drawing canvas pixels, when there are new data, pointX=1080, canvas has left, however, when in drawPoint again, a point by not painting in the most the right side of the screen,
I do not know the pointX, translate how to combine the implementation right into a little left out?

//draw the latest ping 1
For (int n=0; N & lt; MPingData. The size (); N++) {
Double [] point=mPingData. Get (n);
SonarUtils. SonarCard card=SonarUtils. GetColorIdByPointDb (point [0], point [2], the point [1]).
MPaint. SetColor (getResources (). GetColor (card. GetColoValuerId ()));
Float pointY=((float) getHeight ()/(float) mPingData. The size ()) * (float) n;
MBufferCanvas. DrawPoint (pointX, pointY, mPaint);//draw a pixel point of vertical lines
}
MBufferCanvas. Translate (1, 0);
Invalidate ().

CodePudding user response:

refer to 6th floor eddysong9280 response:
the overall effect is when a new vertical lines to draw on the most the right side of the screen, and all is good in front of the vertical bar turn left a pixel,
Look at is the most the right side of the screen the latest vertical bar (vertical bar width is 1 pixel), pushes the vertical bar in front of a little left, right into the line, on the left side of the screen,

Is now in the timer walk the following procedures: pointX=screen width (assuming=1080), the drawPoint always drawn in most the right side of the screen, left a finished drawing canvas pixels, when there are new data, pointX=1080, canvas has left, however, when in drawPoint again, a point by not painting in the most the right side of the screen,
I do not know the pointX, translate how to combine the implementation right into a little left out?

//draw the latest ping 1
For (int n=0; N & lt; MPingData. The size (); N++) {
Double [] point=mPingData. Get (n);
SonarUtils. SonarCard card=SonarUtils. GetColorIdByPointDb (point [0], point [2], the point [1]).
MPaint. SetColor (getResources (). GetColor (card. GetColoValuerId ()));
Float pointY=((float) getHeight ()/(float) mPingData. The size ()) * (float) n;
MBufferCanvas. DrawPoint (pointX, pointY, mPaint);//draw a pixel point of vertical lines
}
MBufferCanvas. Translate (1, 0);
Invalidate ().

Why want to shift to the left? Now this constant redrawing has the effect of the shift to the left,

CodePudding user response:

Redraw the efficiency is low,
Each line consists of hundreds of points, and quickly covered with screen, 1800 (a line to occupy a pixel) * 500 such points, redraw the time-consuming,,,,,,,

CodePudding user response:

I write the code above can realize the shift to the left, but the latest vertical bar is not the most the right side of the screen, translate, pointX=1080 painting point is not the most the right side of the screen, but the left (1080 left the coordinates),
Is pointX++,

CodePudding user response:

If it is straight line, why didn't you just draw lines? Why do you want to draw points?

CodePudding user response:

In fact, that is some point, a bar holds a pixel, a bar, several hundred points about the color of each point is different,
Convenient to describe the problem, I use the line to describe, but the problem is same,

CodePudding user response:


Tried, not what you say

CodePudding user response:

Scrolls effect can be achieved

CodePudding user response:

The
m - refer to 12 floor oj response:

Tried, not what you say


How to implement???? Consult,nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related