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" >
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories