java - how to make a circle slowly "pop" onto the screen -
im making app displays multiple random circles on screen. want know if can expand radius while displaying circle disapeers. have written code randomly display circles here is.
public class splashlaunch extends view{ handler cool = new handler(); drawingview v; objectanimator aa = new objectanimator(); paint newpaint = new paint(); int randomwidthone = 0; int randomheightone = 0; private static int radiusone = 300; final int redcolorone = color.red; final int greencolorone = color.green; private static int lastcolorone; private final random therandom = new random(); public splashlaunch(context context) { super(context); // todo auto-generated constructor stub } private final runnable circleupdater = new runnable() { @suppresslint("newapi") @override public void run() { lastcolorone = therandom.nextint(2) == 1 ? redcolorone : greencolorone; newpaint.setcolor(lastcolorone); cool.postdelayed(this, 500); int x = 0; while(x<=255){ newpaint.setalpha(x); x++; } invalidate(); } }; @override protected void onattachedtowindow(){ super.onattachedtowindow(); cool.post(circleupdater); } protected void ondetachedfromwindow(){ super.ondetachedfromwindow(); cool.removecallbacks(circleupdater); } @override protected void ondraw(canvas canvas) { // todo auto-generated method stub super.ondraw(canvas); if(therandom == null){ randomwidthone =(int) (therandom.nextint(math.abs(getwidth()-radiusone/2)) + radiusone/2f); randomheightone = (therandom.nextint((int)math.abs((getheight()-radiusone/2 + radiusone/2f)))); }else { randomwidthone =(int) (therandom.nextint(math.abs(getwidth()-radiusone/2)) + radiusone/2f); randomheightone = (therandom.nextint((int)math.abs((getheight()-radiusone/2 + radiusone/2f)))); } canvas.drawcircle(randomwidthone, randomheightone, radiusone, newpaint); } }
i want know if can expand radius while displaying circle disappears
yes can. animate scale
of view value greater 1 expand view 0 make "disappear".
Comments
Post a Comment