EquiWare
EquiWare

Reputation: 127

Time delay for Animation

I am trying to use the following code:

m_WebView_Search.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean b) {
            if(m_WebView_Search.hasFocus()){
                Animation mWSE = AnimationUtils.loadAnimation(CoreActivity.this, R.anim.mWSE);
                m_WebView_Search.startAnimation(mWSE);
            }
        }
    });

But only to run after waiting 800ms. So pretty much run the statement but way 800ms before doing it. Is this possible? And if so how can I implant this into the following code. As well if I could make it a variable that would be better cause I would have more instalments of this 800ms Delay. sorry for the little information I really don't know what to post for this issue.

The initial corner radius is 100 each This is the image of the cutoff characters swell as the stretched corners[![][1]]2

Upvotes: 0

Views: 72

Answers (1)

KeLiuyue
KeLiuyue

Reputation: 8237

You can try like this .

1.Use View 's public boolean postDelayed(Runnable action, long delayMillis)

int POST_DELAY_TIME = 2000;
m_WebView_Search.postDelayed(new Runnable() {
    @Override
    public void run() {
        m_WebView_Search.startAnimation(mWSE);
    }
}, POST_DELAY_TIME);

2.Use Handler 's public final boolean postDelayed(Runnable r, long delayMillis)

new Handler().postDelayed(new Runnable() {

    @Override
    public void run() {
        m_WebView_Search.startAnimation(mWSE);
    }
}, POST_DELAY_TIME);

Upvotes: 1

Related Questions