一、Android中的绘图工具类

(1)Android中常见的三种绘图类

  1. Paint(画笔)

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/b80b9fad-0ae3-4311-b8d0-91a97984adf7/Untitled.png

    图形绘制的相关方法:

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/0f2d2eb6-2c7c-4252-bda2-e7d0f4e923e3/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c4806e36-648c-42cc-9bea-d73db384ca1b/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/98ec19b6-41d3-4415-92f4-c0d08e0a8db0/Untitled.png

    文字绘制的相关方法

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/43d7ceb5-9784-45d3-99ae-9e012a4a0a68/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/9f5a46bc-9f86-4097-b514-a52c715cce0f/Untitled.png

  2. Canvas(画布)

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/dc6b640f-e3bd-408f-a1f9-2af1deef7b9e/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/f1d48016-b3c1-4945-9e6d-6f9bc2ffe56a/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/61f9f0f3-849f-48e6-ad3f-c0e524683293/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/880e972a-e002-451a-b590-7d7fc35bb8d8/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/0ef5d900-63d2-4967-a671-365cb60d0d06/Untitled.png

  3. Path(路径)

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/94af4a0d-2bf7-4308-aa70-e0bb00c07d94/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/b59e15a2-ade6-4a1f-abcf-ffd781fa5f21/Untitled.png

安卓中的绘图类:
   1. paint
      用法 : (1)创建画笔   mypaint = new Paint();
                  (2)设置属性 : mypaint.setColor(Color.RED);
        			mypaint.setStyle(Paint.Style.FILL);
       			 mypaint.setStrokeWidth(5);
       			 mypaint.setTextSize(36);
   2. Canvas
           Canvas 对象时ondraw的参数
         使用 canvas对象画画 :
           canvas.drawColor(Color.GREEN);
           canvas.drawCircle(100,100,50,mypaint);
   3. path
        创建path 对象 :  Path path = new Path();
       指定起始位置 path.moveTo(400, 600);
       画线:path.lineTo(500, 700); 参数为终点位置
在Activity中使用绘图类的步骤
  1. 创建绘图类 new ->Java Class
  2. 继承android.view.View : public class MyOwnView extends View {}
  3. 编写构造方法
  4. 重写ondraw方法
  5. 把这个view类设置给Activity
        MyOwnView mView = new MyOwnView(getApplicationContext());
        setContentView(mView);

二、Android中的动画

(1)Android中常见的动画

  1. 逐帧动画(Frame)

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4425d105-209f-491d-b675-3b9664025b34/Untitled.png

  2. 补间动画(Tween)

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4264c1f1-b23d-4940-95ec-e306f5ff9744/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/96ef8f8d-e636-40b0-8da9-aaff4089ce6a/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/42f022da-ad5f-4512-98c7-14af647c5d42/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/dfb6dbf8-e9f4-45e0-a163-7645321e6b8e/Untitled.png

    动画监听:

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/236abfbc-d32a-418c-87c6-d8cf34d89770/Untitled.png

    为View、Fragment动态设置动画效果

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c58c19b8-13b9-4e21-b598-0f8bf3a7e19b/Untitled.png

    为activity设置转场动画

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/2cbdc401-f86d-4041-869c-9ebe0466b74a/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/3d1d5ecd-05f2-4897-93be-71936b08f37f/Untitled.png

  3. 属性动画(Property)

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e53c36ae-de2e-4177-ac4e-4aabf3607bc0/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/72fe10a7-f27b-45f6-8c3d-3d8efd79bb5f/Untitled.png

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/ed0e0e8f-1573-42c9-995a-46753ba6296d/Untitled.png

Android中的动画类型
  1. 逐帧动画 :
     步骤: 1. 定义 在res下创建一个anim目录 编写anim文件。在这个文件中,定义各个静态图片和显示时间
 <animation-list  xmlns:android="<http://schemas.android.com/apk/res/android>"
   		 android:oneshot="false">
    		<item
     		   android:drawable="@mipmap/img_miao1"
       			 android:duration="80" />
                             <item 。。。。>
                     </animation-list>
   2. 定义imageView , 设置imageView的背景图片为刚才定义的anim文件
   3. 在activity 中获取 AnimationDrawable对象  
			  anim= (AnimationDrawable)img.getBackground();
   4.调用start 和stop来控制动画的开始和结束

  2. 补间动画
      步骤 :
         1. 定义 动画类型的XML文件,比如 透明度渐变  缩放渐变等等
         2. 定义一个组件来显示这些渐变
        3. 获取动画对象:animation = AnimationUtils.loadAnimation(this,R.anim.anim_alpha);  -》 第二个参数为XML定义的渐变类型
        4. 调用img.startAnimation(animation); 来启动动画

 3. 属性动画:
     步骤:
       1. 定义组件来显示渐变
       2. 获取动画对象  animator1 = ObjectAnimator.ofFloat(bt,  "alpha", 1f, 0f, 1f, 0f, 1f);
       3.启动动画 animator1.start();

三、Android中的音视频管理

(1)Android中常见的媒体API开发

  1. 利用SoundPool用来播放密集、急促而又短暂的音效

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/7b1dc677-005a-49c2-8808-417322374b02/Untitled.png

  2. 使用MediaRecord录音

    https://s3-us-west-2.amazonaws.com/secure.notion-static.com/37387b9a-5769-4ae3-9ab6-6d1c2f609efd/Untitled.png

  3. 利用MediaPlayer播放音频与视频

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/d9d64882-6df6-48d6-8da1-b50b8bb58d4f/Untitled.png

播放视频:MediaPlayer+SurfaceView、VideoView

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e07becde-e1c8-4019-9ed5-356060ea5c7a/Untitled.png

SoundPool 使用步骤:
   1. 创建SoundPool对象 :
         SoundPool.Builder spb = new SoundPool.Builder();
         spb.setMaxStreams(2);
         sp = spb.build();
  2. 加载音频文件
        HashMap<Integer, Integer> soundID = new HashMap<Integer, Integer>();
        soundID.put(1, sp.load(this,R.raw.biaobiao,1));
        soundID.put(2, sp.load(this,R.raw.fly,1));
3. 播放音频文件
     sp.play(soundID.get(1), 1, 1, 0, 0, 1);
4.释放音频资源
		sp.release();

使用MediaPlayer的步骤:
  1. 创建对象 : mp = android.media.MediaPlayer.create(this,R.raw.fly);  -》第一个参数:当前环境 第二个参数:多媒体文件Id
	本地文件路径:mp.setDataSource("/....")
	网络URL文件:mp.setDataSource("URL")
  2. 播放:  mp.start();
  3. 暂停:  mp.pause();
  4. 停止: mp.stop();
            mp.release();

MediaRecord : 实现录音功能
1. 创建MediaRecord对象
	        mRecorder=new MediaRecorder();
2. 设定声音来源
            mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
3. 设定输出格式
            mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
4. 设定编码格式
            mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
5. 保存文件
				    mRecorder.setOutputFile(path);
6.准备开始
						mRecorder.prepare();
						mRecorder.start();
7.结束
						mRecorder.stop();
						mRecorder.release();

注意事项 : 1. 赋权限 : 在清单文件中加入录音权限
         <uses-permission android:name="android.permission.RECORD_AUDIO" />
        2. 动态权限:
       3. 需要打开手机模拟器的麦克风  -》 setting -》MicroPhone -》 开启
       4. 打开电脑的麦克风  -》 设置 -》 隐私 -》 麦克风

四、使用Camera拍照

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/75ed1ffd-ff8a-4ddc-8453-057e5c7bd6c0/Untitled.png

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/49e79cc5-475b-4fb2-b24e-ed81b10b3750/Untitled.png