您的位置:首页 > 移动开发 > Android开发

Android 简易音乐动态相册(多种动画)

2016-09-17 14:39 399 查看
需要完成效果:点击空白处,音乐与图片同时开始播放,音乐暂停时,图片停止播放。

布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.administrator.jreduch11.PresentActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/show"
android:scaleType="centerCrop"
android:clickable="true"/>
</RelativeLayout>
Activity代码:

package com.example.administrator.jreduch11;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;

import com.example.administrator.jreduch11.effects.BaseEffects;

public class PresentActivity extends AppCompatActivity implements SecondService.StopImg{
private ImageView show;
private boolean run=true;
private boolean click=false;
private int[] imgs={R.mipmap.nannv,R.mipmap.feiji,R.mipmap.ruzi,
R.mipmap.haidi,R.mipmap.meinan,R.mipmap.xingkong};
private Handler handler=new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
start(msg.arg1,2000,msg.what);
}
};

public PresentActivity() {
}

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

show= (ImageView) findViewById(R.id.show);

show.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(click){
return;
}
click=true;
Intent intent=new Intent(PresentActivity.this,SecondService.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startService(intent);
start(0, 5000, 0);
SecondService.setMusicStop(PresentActivity.this);
new Thread(new ImgNext()).start();
}
});

}
private void start(int which,int mDuration,int img) {
show.setImageResource(imgs
完成效果(静态):


[img]https://img-blog.csdn.net/20160917145358935?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" border="0" >








  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Android 图片播放器