Saturday, 2 September 2017

Create Customize Rotate Image

step1:
drawable to save>>   rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"    
      android:duration="1600"    
      android:fromDegrees="380"    
      android:interpolator="@android:anim/linear_interpolator"    
      android:pivotX="50%"    
      android:pivotY="50%"    
      android:repeatCount="infinite"    
      android:toDegrees="0" />

step 2:
public class MainActivity extends AppCompatActivity {

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final ImageView imageView=(ImageView)findViewById(R.id.image);
        Runnable runnable = new Runnable() {
            @Override            public void run() {
                imageView.animate().rotationBy(360).withEndAction(this).setDuration(12000)
                                       .setInterpolator(new LinearInterpolator()).start();
            }
        };

        imageView.animate().rotationBy(360).withEndAction(runnable).setDuration(12000)
                                       .setInterpolator(new LinearInterpolator()).start();
    }
}

No comments:

Post a Comment

HOW TO CREATE CIRCLE IMAGE VIEW

Step 1: implementation 'de.hdodenhof:circleimageview:3.0.0' Step 2: <de.hdodenhof.circleimageview.CircleImageView xmlns:ap...