<!--android:layout_alignParentTop="true"-->
<com.koooke.platform.View.CenterImage
android:id="@+id/centerImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="154dp"
android:scaleType="centerCrop"
android:src="@drawable/koookelogo" />
package com.koooke.platform.View;

import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.animation.LinearInterpolator; import com.koooke.platform.R; /**
* Created by Uniway_125 on 2017/11/27 0027.
*/ public class CenterImage extends android.support.v7.widget.AppCompatImageView {
private Paint paint;
private boolean isCenterImgShow;
private Bitmap bitmap;
public void setCenterImgShow(boolean centerImgShow) {
isCenterImgShow = centerImgShow;
if (isCenterImgShow) {
bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
invalidate();
}
bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
}
public CenterImage(Context context) {
super(context);
init();
}
public CenterImage(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public CenterImage(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
paint = new Paint();
isDrawPoint = true;
}
private boolean isInit = false; private ValueAnimator animator; /********
* 计算圆弧点上的坐标
* 公式:Math.sin(x) x 的正玄值。返回值在 -1.0 到 1.0 之间;
* Math.cos(x) x 的余弦值。返回的是 -1.0 到 1.0 之间的数;
* <p>
* X指的是弧度 因此
* <p>
* 30° 角度 的弧度 = 2*PI/360*30
* <p>
* 圆上每个点的X坐标=a + Math.sin(2*Math.PI / 360) * r
* Y坐标=b + Math.cos(2*Math.PI / 360) * r ;
**************/
private boolean isDrawPoint = false;
public void setDrawPoint(boolean drawPoint) {
isDrawPoint = drawPoint;
}
// @Override
// protected void onDraw(Canvas canvas) {
// super.onDraw(canvas);
// if ( bitmap != null) {
//
// System.out.println(String.format("wight %d,height %d",getWidth(),getHeight()));
// Paint paint2 = new Paint();
// paint2.setStyle(Paint.Style.FILL);
// paint2.setColor(Color.WHITE);
// canvas.drawCircle( getMeasuredWidth()/2 , 3 ,smallBallWidth, paint2);
// //canvas.drawBitmap(bitmap, getMeasuredWidth() / 2 +50, getMeasuredHeight(), paint);
// Paint paint3 = new Paint();
// paint3.setStyle(Paint.Style.FILL);
// paint3.setColor(Color.WHITE);
//
// canvas.drawCircle( getMeasuredWidth()/2 , getMeasuredHeight()-3,smallBallWidth, paint3);
// }
// }
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
r = getMeasuredWidth()/2;
Paint paint2 = new Paint();
paint2.setStyle(Paint.Style.FILL);
paint2.setColor(Color.WHITE);
canvas.drawCircle( getMeasuredWidth()/2 , smallBallWidth ,smallBallWidth, paint2); //canvas.drawBitmap(bitmap, getMeasuredWidth() / 2 +50, getMeasuredHeight(), paint);
Paint paint3 = new Paint();
paint3.setStyle(Paint.Style.FILL);
paint3.setColor(Color.WHITE);
canvas.drawCircle( getMeasuredWidth()/2 , getMeasuredHeight()-smallBallWidth,smallBallWidth, paint3); }
private void MathDisc(Canvas canvas,Paint inputPaint,float base ) { //angle 角度 float hudu = (float) ((2 * Math.PI / 360) * (angle))+base; // 360/8=45,即45度(这个随个人设置)
float X = (float) (r + smallBallWidth + Math.sin(hudu) * r); // r+5 是圆形中心的坐标X 即定位left 的值
float Y = (float) (r + smallBallWidth - Math.cos(hudu) * r); // r+5 是圆形中心的坐标Y 即定位top 的值
System.out.println(String.format("X = %f y = %f",X, Y));
canvas.drawCircle(X, Y, smallBallWidth, inputPaint);
canvas.restore(); }
private int r = 0;//半径
private int smallBallWidth = 4;
/********
* 计算圆弧点上的坐标
* 公式:Math.sin(x) x 的正玄值。返回值在 -1.0 到 1.0 之间;
* Math.cos(x) x 的余弦值。返回的是 -1.0 到 1.0 之间的数;
* <p>
* X指的是弧度 因此
* <p>
* 30° 角度 的弧度 = 2*PI/360*30
* <p>
* 圆上每个点的X坐标=a + Math.sin(2*Math.PI / 360) * r
* Y坐标=b + Math.cos(2*Math.PI / 360) * r ;
**************/
// private void MathDisc(Canvas canvas) { //angle 角度
// if (isDrawPoint) {
// float hudu = (float) ((2 * Math.PI / 360) * (angle)); // 360/8=45,即45度(这个随个人设置)
// float X = (float) (r + 5 + Math.sin(hudu) * r); // r+5 是圆形中心的坐标X 即定位left 的值
// float Y = (float) (r + 5 - Math.cos(hudu) * r); // r+5 是圆形中心的坐标Y 即定位top 的值
// canvas.drawCircle(X, Y, smallBallWidth, circleRing);
// canvas.restore();
// }
// } private float angle = 0;
public void startAnimation() {
animator = ValueAnimator.ofFloat(0, 1.0f);
//动画时长,让进度条在CountDown时间内正好从0-360走完,
animator.setDuration(1000);
animator.setInterpolator(new LinearInterpolator());//匀速
animator.setRepeatCount(-1);//表示不循环,-1表示无限循环
//值从0-1.0F 的动画,动画时长为countdownTime,ValueAnimator没有跟任何的控件相关联,那也正好说明ValueAnimator只是对值做动画运算,而不是针对控件的,我们需要监听ValueAnimator的动画过程来自己对控件做操作
//添加监听器,监听动画过程中值的实时变化(animation.getAnimatedValue()得到的值就是0-1.0)
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
/**
* 这里我们已经知道ValueAnimator只是对值做动画运算,而不是针对控件的,因为我们设置的区间值为0-1.0f
* 所以animation.getAnimatedValue()得到的值也是在[0.0-1.0]区间,而我们在画进度条弧度时,设置的当前角度为360*currentAngle,
* 因此,当我们的区间值变为1.0的时候弧度刚好转了360度
*/
angle = 360 * (float) animation.getAnimatedValue();
invalidate();//实时刷新view,这样我们的进度条弧度就动起来了
}
});
//开启动画
animator.start();
}
}

android测试Code的更多相关文章

  1. 【Android测试】【随笔】模拟双指点击

    ◆版权声明:本文出自胖喵~的博客,转载必须注明出处. 转载请注明出处:http://www.cnblogs.com/by-dream/p/5258660.html 手势 看到这个标题,很多人会想一想 ...

  2. 【Android测试】【随笔】模拟长按电源键

    ◆版权声明:本文出自胖喵~的博客,转载必须注明出处. 转载请注明出处:http://www.cnblogs.com/by-dream/p/5195121.html 起因 昨天群里看到有人问如何实现一个 ...

  3. 5个最佳的Android测试框架(带示例)

    谷歌的Android生态系统正在不断地迅速扩张.有证据表明,新的移动OEM正在攻陷世界的每一个角落,不同的屏幕尺寸.ROM /固件.芯片组以及等等等等,层出不穷.于是乎,对于Android开发人员而言 ...

  4. Android Secret Code

    我们很多人应该都做过这样的操作,打开拨号键盘输入*#*#4636#*#*等字符就会弹出一个界面显示手机相关的一些信息,这个功能在Android中被称为android secret code,除了这些系 ...

  5. Android测试提升效率批处理脚本(三)

    前言: 前面放出过几次批处理,这次只放一个环境检查的被管理员给打回来了,不得不再找找几个有含金量的放出来,请看正文~~~ 目录 1.Android环境检查 2.Android内存监控 3.模拟蓝牙手柄 ...

  6. Android测试基础题(三)

    今天接着给大家带来的是Android测试基础题(三).    需求:定义一个排序的方法,根据用户传入的double类型数组进行排序,并返回排序后的数组 俗话说的好:温故而知新,可以为师矣 packag ...

  7. Android测试提升效率批处理脚本(二)

    前言: 前面放出过一次批处理,本次再放出一些比较有用的批处理(获得当前包名.查看APP签名信息等),好长时没来写博客了,简单化,请看正文,更多脚本尽请期待~~~(不定期) 目录 1.[手机录屏(安卓4 ...

  8. iOS 和 Android 测试托管平台 FIR.im 的注册与常用功能

    FIR.im  作为专业的 iOS 和 Android 测试包发布网站, 注册超简单,支持输入网址直接下载和二维码扫描下载.功能类似 TestFlight ,但又比它强大,支持游客访问密码,iOS 和 ...

  9. 【Android测试】【第十七节】Instrumentation——App任你摆布(反射技术的引入)

    ◆版权声明:本文出自胖喵~的博客,转载必须注明出处.  转载请注明出处:http://www.cnblogs.com/by-dream/p/5569844.html 前言 学习了上节之后,大家是否已经 ...

随机推荐

  1. Android微信支付流程及返回码-1之坑

    http://www.51testing.com/html/36/n-3724336.html 之前做微信支付的时候,直接是以库形式引入项目的,虽然一直觉得微信支付的开发文档不太理想,但是印象中也没有 ...

  2. LoadRunner性能测试结果分析(转载)

    性能测试的需求指标:本次测试的要求是验证在30分钟内完成2000次用户登录系统,然后进行考勤业务,最后退出,在业务操作过程中页面的响应时间不超过3秒,并且服务器的CPU使用率.内存使用率分别不超过75 ...

  3. cordova build android 环境的坑

    毕业设计的选题为一个app,native app学起来在时间上有些不足,因此选择了hybird app ;cordova就不介绍了,本文主要是写在cordova bulid android时所遇到的问 ...

  4. git学习笔记5

    查看保存的进度 git stash list 恢复进度 git stash pop 测试运行哪些文件会被删除 git clean -nd 强制删除 git clean -fd 保存当前的工作进度,会保 ...

  5. Android Gson解析复杂Json

    JSON原数据 {"total":1,"rows":[{"ID":1,"Title":"台州初级中学招收初一年 ...

  6. MySql的备份还原

    备份数据是数据库管理最常用的操作.为了保证数据库中数据的安全,数据管理员需要定期进行数据备份.一旦数据库遭到破坏,便可通过备份的文件来还原数据库.因此,数据备份是一项很重要的工作. 数据备份 使用my ...

  7. 【c++】流状态的查询和控制

    源自 c++primer 4th, 248页 代码 #include <iostream> #include <limits> #include <stdexcept&g ...

  8. Codeforces 156 A——Message——————【思维题】

    A. Message time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...

  9. StrangeIoc框架学习

    StrangeIoc是一款基于MVCS的一种框架,是对MVC思想的扩展,是专门针对Unity3D开发的一款框架,非常好用. 一.MVCS分别代表什么 MVCS框架是一种模块的分离,一种写代码的规则,目 ...

  10. SP16580 QTREE7 - Query on a tree VII

    Description 一棵树,每个点初始有个点权和颜色(0/1) 0 u :询问所有u,v 路径上的最大点权,要满足u,v 路径上所有点的颜色都相同 1 u :反转u 的颜色 2 u w :把u 的 ...