1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | public class MyActivity extends Activity { private View iv; /** * Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); iv = findViewById(R.id.iv); iv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { view.animate().translationXBy(5.f).setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) view.getLayoutParams(); lp.leftMargin += 5; view.requestLayout(); } }); } }); } } |
Direct link: https://paste.plurk.com/show/1841668