package com.liuyang.code.controllers;

import android.animation.ObjectAnimator;
import android.widget.TextView;

import com.liuyang.code.R;
import com.liuyang.code.widgets.ScrollerView;

/**
 * @author Liuyang 2016/3/22.
 */
public class ViewBasis extends BaseFragment {
    private int i = 0;

    @Override
    protected int layoutId() {
        return R.layout.view_basis;
    }

    @Override
    protected void init() {
        ScrollerView view = find(R.id.scroller_view);
        view.setOnClickListener(l -> {
            if (i++ % 2 == 0) {
                view.smoothScrollTo(-100, 0);
            } else {
                view.smoothScrollTo(0, 0);
            }
        });

        TextView animationView = find(R.id.animation_view);
        animationView.setOnClickListener(l -> {
            if (i++ % 2 == 0) {
                ObjectAnimator.ofFloat(animationView, "translationX", 0, 100).setDuration(1000).start();
            } else {
                ObjectAnimator.ofFloat(animationView, "translationX", 100, 0).setDuration(1000).start();
            }
        });
    }

    @Override
    protected void refresh() {

    }
}

@@ -73,16 +73,47 @@
 imator;%0A
+import android.view.ViewGroup;%0A
 import a
@@ -763,32 +763,138 @@
 nimation_view);%0A
+        ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) animationView.getLayoutParams();%0A
         animatio
@@ -949,32 +949,66 @@
 i++ %25 2 == 0) %7B%0A
+                lp.topMargin = 0;%0A
                 
@@ -1109,32 +1109,67 @@
        %7D else %7B%0A
+                lp.topMargin = 20;%0A
                 
@@ -1263,32 +1263,79 @@
 ;%0A            %7D%0A
+            animationView.setLayoutParams(lp);%0A
         %7D);%0A    
@@ -1330,16 +1330,17 @@
     %7D);%0A
+%0A
     %7D%0A%0A 

modify layout params to animate