我爲圖片製作了一個簡單的動畫,並在圖片上設置了事件OnClick來製作敬酒。問題是我使圖像開始在onCreate上進行動畫,並且我設置了要點擊的圖像並啓動了烘烤,但問題在於圖像不可點擊,但是如果我按下原始位置圖像,麪包開始(圖像不與動畫移動)如何使動畫在Android中可點擊
THX對您有所幫助
這是動畫文件夾中的動畫代碼(translate.xml)
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<translate
android:fromXDelta="-80%p"
android:toXDelta="80%p"
android:duration="20000"
android:repeatCount="100"
android:repeatMode="restart"
/>
</set>
這是活動分類
package com.example.animatest;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.Toast;
public class MainActivity extends Activity {
private ImageView image01;
private long aefe;
private ImageView image1;
private ImageView image2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
image01 = (ImageView) findViewById(R.id.imageView1);
final Animation animTranslate1 = AnimationUtils.loadAnimation(this,
R.anim.translate);
image01.startAnimation(animTranslate1);
image01.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "hello", Toast.LENGTH_SHORT)
.show();
}
});
}
}
你的意思是:'但如果我按下圖像的原始位置,開始吐司(圖像不隨動畫移動)'你能添加一些截圖嗎?它很難理解。 – 2013-02-14 18:29:54
我的意思是,如果點擊圖片的吐司將開始,但如果我點擊圖片時,它正在做動畫什麼都沒有發生 – 2013-02-14 18:32:13
要更清楚你的圖像做動畫從左到右在屏幕我想用戶,如果他點擊圖片時,它正在做動畫吐司將開始 – 2013-02-14 18:34:32