为了账号安全,请及时绑定邮箱和手机立即绑定

学习 《Android猜歌游戏是这样炼成的》第三章课程时,遇到几个问题,请老师们指导

1、在学习 《Android猜歌游戏是这样炼成的》第三章课程时,遇到几个问题,请老师们指导


问题如下:

1、盘片无法实现转动三圈

2、播放按钮上有白色阴影

3、拨杆在音乐播放期间不会自动停止在盘片上

549a704a00017eda03100341.jpg


无法上传附件。。


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();

    }

}


正在回答

2 回答

都有定义啊,一直找不到问题出在哪里

549a7c51000199e005000173.jpg

0 回复 有任何疑惑可以回复我~

你有没有在动画的xml文件中定义

android:repeatCount="3"


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Android猜歌游戏是这样炼成的
  • 参与学习       27735    人
  • 解答问题       422    个

手把手教你完成一款猜歌类游戏,向你展示游戏实现的全部细节

进入课程

学习 《Android猜歌游戏是这样炼成的》第三章课程时,遇到几个问题,请老师们指导

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信