I have the following CustomView
I am using for painting in my app:
package com.test.testing;
import android.content.Context;
import android.gra
You're adding to a single path with each TouchEvent. Then the Path is drawn using the current value of the Paint's color. That's why you are seeing everything drawing in a single color. You would need to create a separate Path and color for each color change and then draw them in sequence, changing the Paint's color for each drawPath() call
I don't think so. It's not that bad to break out the paths.
List<Pair<Path, Integer>> path_color_list = new ArrayList<Pair<Path,Integer>>()
then each time you change the color. Take the current path and view.paint.getColor and save it to your list.
path_color_list.add( new Pair.create(path, view.paint.getColor());
path = new Path();
then in your draw() iterate through the path_color_list, setting the new paint color each time
for (Pair<Path,Integer> path_clr : path_color_list ){
paint.setColor(path_clr.second);
canvas.drawPath( path_clr.first, paint);
}
followed with the last drawPath() that you have
Just do one thing always create new instance of your view
class view1.paint.setColor(Color.LTGRAY);
,
then layout.addView(view1);
means create new view it will save prevoius one also,
its work for me. Very simple!!