Hello, dear friends if you want to create scanner animation with shape design then follow this steps.
Create drawable file name of line_shape.xml
Create drawable file name of line_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="line">
<solid android:color="#0000FF" />
<size
android:width="480dp"
android:height="10dp" />
<corners android:radius="1dp" />
<stroke
android:width="3dp"
android:color="#000000" />
</shape>
</item>
<item android:top="30dp">
<shape android:shape="line">
<solid android:color="#0000FF" />
<size
android:width="480dp"
android:height="10dp" />
<corners android:radius="1dp" />
<stroke
android:width="3dp"
android:color="#000000" />
</shape>
</item>
<item android:top="60dp">
<shape android:shape="line">
<solid android:color="#0000FF" />
<size
android:width="480dp"
android:height="10dp" />
<corners android:radius="1dp" />
<stroke
android:width="3dp"
android:color="#000000" />
</shape>
</item>
</layer-list>
MainActivity.java
private ImageView ivscanner;
onCreate(Bundle saveinstance){
setContentView(R.layout.mainactivity);
startScan();
}
public void startScan(){
ivscanner.setVisibility(View.VISIBLE);
mAnimation = new TranslateAnimation(
TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.ABSOLUTE, 0f,
TranslateAnimation.RELATIVE_TO_PARENT, 0f,
TranslateAnimation.RELATIVE_TO_PARENT, 1.0f);
mAnimation.setDuration(9000);
mAnimation.setRepeatCount(-1);
mAnimation.setRepeatMode(Animation.REVERSE);
mAnimation.setInterpolator(new LinearInterpolator());
ivscanner.setAnimation(mAnimation);
}
No comments:
Post a Comment