Updated 13 October 2017
In this blog, I will show you how can we aware the users for the wrong input or something went wrong. There are simple two way to alert your users or customer for the wrong input.
Step 1: Create the object for the Vibrator class,
1 private Vibrator vibrateObject;
Step 2: Below is the block of code for which vibrate the device for the 200 millisecond,
123 vibrateObject = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);// Vibrate for 200 millisecondsvibrateObject.vibrate(200);
Step 3: Add permission in Manifest.xml
1 <uses-permission android:name="android.permission.VIBRATE" />
Step 1: Create your shake error file,
123456 <?xml version="1.0" encoding="utf-8"?><translate xmlns:android="http://schemas.android.com/apk/res/android"android:duration="300"android:fromXDelta="0"android:interpolator="@anim/cycle_2"android:toXDelta="20" />
Step 2: Create the Interpolator,
123 <?xml version="1.0" encoding="utf-8"?><cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"android:cycles="2" />
Step 3: Apply on Views or text which you want to Shake or wobble,
12 findViewById(R.id.textView).startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.shake_error));findViewById(R.id.simpleView).startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.shake_error));
If you have any doubt on this blog, please ask in comments. And stay updated and stay super.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.