You can use these functions in API 11
((TextView)findViewById(R.id.textView)).setTranslationX(200); ((TextView)findViewById(R.id.textView)).setTranslationY(300);
Update Try this code code code.
final TextView tv = (TextView)findViewById(R.id.textView); new Timer().schedule(new TimerTask() { @Override public void run() { MainActivity.this.runOnUiThread(new Runnable() { public void run() { tv.setTranslationX(tv.getTranslationX()+10); tv.setTranslationY(tv.getTranslationY()+10); tv.invalidate(); } }); } }, 1000 , 1000); tv.setOnClickListener(new OnClickListener() { public void onClick(View v) { Toast.makeText(getApplicationContext(), "Clicked!", Toast.LENGTH_SHORT).show(); } });
Refresh
To realize what you showed in the picture. Here is a short description to implement this
Create path arrays (a 2D point array) for each view on which
views will travel
Create timers for each view with a repetition interval of 100 ms or less, as needed.
In these timers, get a point from this array of paths and pass it to your view.
The cycle along this path forever means a circular way.
set a onClck() Listener for this view.
In this listener, cancel () the appropriate timer for this view and destroy that view or set the visibility to GONE.
In order for all this to be implemented, you can easily complete this task.
source share