学习 《Android猜歌游戏是这样炼成的》第三章课程时,遇到几个问题,请老师们指导
1、在学习 《Android猜歌游戏是这样炼成的》第三章课程时,遇到几个问题,请老师们指导
问题如下:
1、盘片无法实现转动三圈
2、播放按钮上有白色阴影
3、拨杆在音乐播放期间不会自动停止在盘片上
无法上传附件。。
package com.imooc.guessmusic.ui;
import com.imooc.guessmusic.R;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Toast;
public class MainActivity extends ActionBarActivity {
//唱片相关动画
private Animation mPanAnim;
private LinearInterpolator mPanLin;
private Animation mBarInAnim;
private LinearInterpolator mBarInLin;
private Animation mBarOutAnim;
private LinearInterpolator mBarOutLin;
private ImageView mViewPan;
private ImageView mViewPanBar;
private ImageButton mBtnPlayStart;
private boolean mIsRunning = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBtnPlayStart = (ImageButton)findViewById(R.id.btn_paly_start);
mBtnPlayStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
//Toast.makeText(MainActivity.this, "hello", Toast.LENGTH_LONG).show();
handlePlayButton();
}
});
mViewPan = (ImageView)findViewById(R.id.imageView1);
mViewPanBar = (ImageView)findViewById(R.id.imageView2);
mPanAnim = AnimationUtils.loadAnimation(this, R.anim.rotate);
mPanLin = new LinearInterpolator();
mPanAnim.setInterpolator(mPanLin);
mPanAnim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mViewPanBar.startAnimation(mBarOutAnim);
}
});
mBarInAnim = AnimationUtils.loadAnimation(this, R.anim.rotate_45);
mBarInLin = new LinearInterpolator();
mBarInAnim.setFillAfter(true);
mBarInAnim.setInterpolator(mBarInLin);
mBarInAnim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Log.i("唱片动画", "22222222222");
mViewPan.startAnimation(mPanAnim);
}
});
mBarOutAnim = AnimationUtils.loadAnimation(this, R.anim.rotate_d_45);
mBarOutLin = new LinearInterpolator();
mBarOutAnim.setFillAfter(true);
mBarOutAnim.setInterpolator(mBarOutLin);
mBarOutAnim.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Log.i("test", "1111111111111111111111111");
mIsRunning = false;
mBtnPlayStart.setVisibility(View.VISIBLE);
}
});
}
private void handlePlayButton(){
if(mViewPanBar != null){
if(!mIsRunning){
mIsRunning = true;
mViewPanBar.startAnimation(mBarInAnim);
mBtnPlayStart.setVisibility(View.INVISIBLE);
}
}
}
@Override
public void onPause() {
mViewPan.clearAnimation();
super.onPause();
}
}