/**
* 切换播放状态
* */
private void trigger(){
if(isPlaying){
stopMusic();
}else{
playMusic();
}
}
/**
* 播放音乐
* */
public void playMusic(){
isPlaying=true;
mIvPlay.setVisibility(View.GONE);
mFlPlayMusic.startAnimation(mPlayMusicAnim);
mIvNeedle.startAnimation(mPlayNeedleAnim);
}
/**
* 停止播放
* */
public void stopMusic(){
isPlaying=false;
mIvPlay.setVisibility(View.VISIBLE);
mFlPlayMusic.clearAnimation();
mIvNeedle.startAnimation(mStopNeedleAnim);
}
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
//光盘
<FrameLayout
android:id="@+id/fl_play_music"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/discTopSize">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/disc"/>
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/iv_icon"
android:layout_width="@dimen/playMusicIconSize"
android:layout_height="@dimen/playMusicIconSize"
android:layout_gravity="center"
app:civ_border_width="2dp"
app:civ_border_color="@android:color/white"/>
<ImageView
android:id="@+id/iv_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/play_music"
android:layout_gravity="center"
android:visibility="gone"/>
</FrameLayout>
//指针
<ImageView
android:id="@+id/iv_needle"
android:layout_width="220dp"
android:layout_height="220dp"
android:src="@mipmap/needle"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="25dp"
android:layout_marginTop="@dimen/discTopSize"></ImageView>
</FrameLayout>