I want to implement this button Where the grey background image would be moving from left to right in infinite loop.
Basically the animated grey colour tilted background from left to right.
I want to implement this button Where the grey background image would be moving from left to right in infinite loop.
Basically the animated grey colour tilted background from left to right.
On
xml: under your button:
<View
android:id="@+id/shine"
android:layout_width="30dp"
android:layout_height="113dp"
android:layout_marginTop="-7dp"
android:layout_marginBottom="-7dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="-40dp"
android:background="@drawable/bg_shine"
android:rotation="20" />
bg_shine:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:centerColor="#AAffffff"
android:endColor="#00ffffff"
android:startColor="#00ffffff"/>
</shape>
and code:
View shine = view.findViewById(R.id.shine);
shineAnimation(shine);
and:
private void shineAnimation(View view) {
// attach the animation layout Using AnimationUtils.loadAnimation
Animation anim = AnimationUtils.loadAnimation(requireContext(), R.anim.left_right);
view.startAnimation(anim);
// override three function There will error
// line below the object
// click on it and override three functions
anim.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
new Handler(Looper.getMainLooper()).postDelayed(() -> view.startAnimation(anim), 5000);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
}
You can achieve it by this way. First create an animate vector drawable
Next, put it to your layout
Finally, implement it in Activity