Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,813,583 Members 38,424 Now Online
XDA Developers Android and Mobile Development Forum

Create Particles that will follow you"re finger

Tip us?
SpaceCaker's Avatar
Recognized Themer / Contributor - OP
Thanks Meter 10,731
Posts: 13,326
Join Date: Mar 2011
Location: netherlands
Default Create Particles that will follow you"re finger

As the title suggests.

I have seen this in xperia z2 lockscreen and wanted to recreate that effect
I googled arround but only found some which also needed me to create a game of it which i dont want

I want to have a view and can simply move my finger in it and let sparkles,particles,smoke etc drag under it

Anyone knows how?

Sent from my C5303 using XDA Free mobile app

My Github Click Here
Check My SoundCloud for my music remakes,mixes etc Click Here
Check My Website to find a portfolio and about me Click Here
mohamedrashad's Avatar
Senior Member
Thanks Meter 443
Posts: 942
Join Date: Nov 2012
Location: ismailia
Create a view (sparkles or whatever) and at ontouch listener update the parameters of X & Y
I made this in a previous app of mine (Floata) but you can adapt it to the app

here you are :

Adding the view :

	twitterp = new WindowManager.LayoutParams(

		twitterp.gravity = Gravity.TOP | Gravity.LEFT;
		twitterp.x = 0;
		twitterp.y = 0;

		windowManager.addView(twitter, twitterp);

twitter.setOnTouchListener(new View.OnTouchListener() {

			private int initialX;
			private int initialY;
			private float initialTouchX;
			private float initialTouchY;

			public boolean onTouch(View v, MotionEvent event) {


				switch (event.getAction()) {

				case MotionEvent.ACTION_DOWN:
					initialX = twitterp.x;
					initialY = twitterp.y;
					initialTouchX = event.getRawX();
					initialTouchY = event.getRawY();

					return false;

				case MotionEvent.ACTION_UP:

					return false;
				case MotionEvent.ACTION_MOVE:
					twitterp.x = initialX
							+ (int) (event.getRawX() - initialTouchX);
					twitterp.y = initialY
							+ (int) (event.getRawY() - initialTouchY);

					windowManager.updateViewLayout(twitter, twitterp);


					return false;

				return false;

this is a floating object (like a chathead of Fb messenger) , you can use the samew concept in your app i think
Pi Locker Major Update 4.0 >>> Google play || XDA

Founder of Pi Developers

Website || Github || Blog

Floata || Pi Locker || Socials addict

The Following User Says Thank You to mohamedrashad For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes