录制音频时播放动画

时间:2014-01-02 07:17:36

标签: android animation

我正在开发虚拟cigaratte,其中我正在使用图像和帧动画我想在录制音频时播放动画...可以对这个应用程序有任何想法吗?

我的代码在

之下
public class MainActivity extends Activity {
ImageView imageView;
AnimationDrawable animation;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    imageView=(ImageView)findViewById(R.id.imageView1);
    imageView.setBackgroundResource(R.drawable.myanim);
    animation=(AnimationDrawable)imageView.getBackground();
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
    // TODO Auto-generated method stub
    super.onWindowFocusChanged(hasFocus);
    if (hasFocus) {
        animation.start();
    }
    else {
        animation.stop();
    }
}

}

1 个答案:

答案 0 :(得分:1)

public class MainActivity extends Activity {
ImageView imageView;
Button record,stop;
AnimationDrawable animation;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

imageView=(ImageView)findViewById(R.id.imageView1);
record   =(Button)findViewById(R.id.record);
stop     =(Button)findViewById(R.id.stop);
imageView.setBackgroundResource(R.drawable.myanim);
animation=(AnimationDrawable)imageView.getBackground();

record.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
  //do your function of record
  animation.start();
}}

stop.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
  //do your function of record
  animation.stop();
}}

}


}