N
N
ngapp2020-01-09 17:50:50
Android
ngapp, 2020-01-09 17:50:50

How to keep the position of the TextView after the animation is done and not repeat it on further clicks?

Hello everyone,
The situation is this, By clicking on the marker on the Google map with the onMarkerClick event, the animation is triggered and a TextView appears. However, with repeated clicks, the animation repeats to fire. How to fix the position and not play the animation when clicking on the marker again?

@Override
    public boolean onMarkerClick(Marker marker) {
          if (marker.equals(marker)) {
            btn1 = findViewById(R.id.btn_sensor);
            btn2 = findViewById(R.id.btn_stop);
            txt1 = findViewById(R.id.textView);
            txt1.setVisibility(View.VISIBLE);
            btn1.show();
            btn2.show();
            startAnimation();
        }
        return false;
    }

private void startAnimation() {
        Animation animtext_in = AnimationUtils.loadAnimation(this, R.anim.animtext_in);
        Animation animbuttons_in = AnimationUtils.loadAnimation(this, R.anim.animbuttons_in);
        txt1.startAnimation(animtext_in);
        btn1.startAnimation(animbuttons_in);
        btn2.startAnimation(animbuttons_in);
        animtext_in.setFillAfter(true);
        animbuttons_in.setFillAfter(true);
    }

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <translate
        android:duration="500"
        android:fromYDelta="-15%p"
        android:toYDelta="0%p" />
</set>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question