当前位置: 首页 > news >正文

不会写代码如何做网站赤峰城乡建设局网站

不会写代码如何做网站,赤峰城乡建设局网站,网站建设步骤及推广方法,旅游网站专业化建设的要点2019独角兽企业重金招聘Python工程师标准 看了ApiDemo里面的BoucingBall#xff0c;觉得挺好的#xff0c;所以特地学习了一下#xff0c;将代码注释后贴到这里#xff0c;以便以后学习。 class BallView extends View implements ValueAnimator.AnimatorUpd… 2019独角兽企业重金招聘Python工程师标准      看了ApiDemo里面的BoucingBall觉得挺好的所以特地学习了一下将代码注释后贴到这里以便以后学习。 class BallView extends View implements ValueAnimator.AnimatorUpdateListener{private static final int RED 0xffFF8080;private static final int BLUE 0xff8080FF;private static final int CYAN 0xff80ffff;private static final int GREEN 0xff80ff80;private ArrayListShapeHolder balls new ArrayListShapeHolder();public BallView(Context context, AttributeSet attrs, int defStyle) {super(context, attrs, defStyle);// TODO Auto-generated constructor stub}public BallView(Context context) {this(context, null);}public BallView(Context context, AttributeSet attrs) {super(context, attrs);//自定义View的背景切换动画ValueAnimator colorAnim ObjectAnimator.ofInt(this,backgroundColor, RED, BLUE,CYAN,GREEN);colorAnim.setDuration(3000L);colorAnim.setEvaluator(new ArgbEvaluator());colorAnim.setRepeatCount(ValueAnimator.INFINITE);colorAnim.setRepeatMode(ValueAnimator.REVERSE);colorAnim.start();}Overrideprotected void onDraw(Canvas canvas) {//在画布上绘制图形for(ShapeHolder holder:balls){canvas.save();canvas.translate(holder.getX(), holder.getY());holder.getmShapeDrawable().draw(canvas);canvas.restore();}}Overridepublic boolean onTouchEvent(MotionEvent event) {if (event.getAction() ! MotionEvent.ACTION_DOWN event.getAction() ! MotionEvent.ACTION_MOVE) {return false;}ShapeHolder newBall addBall(event.getX(), event.getY());float startY newBall.getY();float endY getHeight() - 50f;float h getHeight();float eventy event.getY();int duration (int) (500 * ((h - eventy) / h));//设置加速掉落的效果ValueAnimator bounceAnim ObjectAnimator.ofFloat(newBall, y,startY, endY);bounceAnim.setDuration(duration);bounceAnim.setInterpolator(new AccelerateInterpolator());//当掉落到底部的时候球体压扁高度降低ValueAnimator squashAnim1 ObjectAnimator.ofFloat(newBall, x,newBall.getX(), newBall.getX() - 25);squashAnim1.setDuration(duration /4);squashAnim1.setRepeatCount(1);squashAnim1.setRepeatMode(ValueAnimator.REVERSE);squashAnim1.setInterpolator(new DecelerateInterpolator());ValueAnimator squashAnim2 ObjectAnimator.ofFloat(newBall,width, newBall.getWidth(), newBall.getWidth() 50);squashAnim2.setDuration(duration /4);squashAnim2.setRepeatCount(1);squashAnim2.setRepeatMode(ValueAnimator.REVERSE);squashAnim2.setInterpolator(new DecelerateInterpolator());ValueAnimator strechAnim1 ObjectAnimator.ofFloat(newBall, y,endY, endY 25);strechAnim1.setDuration(duration /4);strechAnim1.setRepeatCount(1);strechAnim1.setRepeatMode(ValueAnimator.REVERSE);strechAnim1.setInterpolator(new DecelerateInterpolator());ValueAnimator strechAnim2 ObjectAnimator.ofFloat(newBall,height,newBall.getHeight(), newBall.getHeight() - 25);strechAnim2.setDuration(duration /4);strechAnim2.setRepeatCount(1);strechAnim2.setRepeatMode(ValueAnimator.REVERSE);strechAnim2.setInterpolator(new DecelerateInterpolator());ValueAnimator bounceBack ObjectAnimator.ofFloat(newBall, y,endY, startY25);bounceBack.setDuration(duration);bounceAnim.setInterpolator(new DecelerateInterpolator());AnimatorSet set new AnimatorSet();set.play(bounceAnim).before(squashAnim1);set.play(squashAnim1).with(squashAnim2);set.play(squashAnim1).with(strechAnim1);set.play(squashAnim1).with(strechAnim2);set.play(bounceBack).after(strechAnim2);//逐渐消失ValueAnimator fadeAnimator ObjectAnimator.ofFloat(newBall,alpha, 1F, 0F);fadeAnimator.setDuration(600L);fadeAnimator.addListener(new AnimatorListenerAdapter() {Overridepublic void onAnimationEnd(Animator animation) {// TODO Auto-generated method stubballs.remove(((ObjectAnimator) animation).getTarget());}});AnimatorSet animationSet new AnimatorSet();animationSet.play(set).before(fadeAnimator);animationSet.start();return true;}/*** 生成一个球* param x* param y* return*/public ShapeHolder addBall(float x, float y) {// 构造一个圆形的图案OvalShape oval new OvalShape();oval.resize(50f, 50f);ShapeDrawable draw new ShapeDrawable(oval);ShapeHolder holder new ShapeHolder(draw);holder.setX(x - 25);holder.setY(y - 25);int red (int) (Math.random() * 255);int green (int) (Math.random() * 255);int blue (int) (Math.random() * 255);int color 0xff000000 | red 16 | green 8 | blue;int darkColor 0xff000000 | red / 4 16 | green / 4 8 | blue/ 4;Paint paint draw.getPaint();RadialGradient gradient new RadialGradient(12.5f, 12.5f, 50f,color, darkColor, Shader.TileMode.CLAMP);paint.setShader(gradient);holder.setmRadialGradient(gradient);holder.setmPaint(paint);balls.add(holder);return holder;}Overridepublic void onAnimationUpdate(ValueAnimator animation) {// TODO Auto-generated method stubinvalidate();} } 转载于:https://my.oschina.net/fengcunhan/blog/52763
http://www.zqtcl.cn/news/857259/

相关文章:

  • 房地产手机网站模板电脑建立网站
  • 网站自适应手机代码网络服务机构的网站
  • 系统网站重庆智能建站模板
  • wordpress适合优化吗宝塔 wordpress优化
  • 怎么利用网站做外链接怎样做公司网站介绍
  • 广州网站优化渠道木门网站模板
  • 手机网站菜单设计wordpress加联系方式
  • 网站管理助手怎么使用多种郑州网站建设
  • 汉中网站建设费用外贸网站服务商
  • 苏宿工业园区网站建设成功案例色流网站如何做
  • 北沙滩网站建设公司电子商务网站建设管理论文
  • 公司备案证查询网站查询系统网页设计html代码大全及含义
  • 成都开发网站建设做网站一般会出现的问题
  • 企业网站设计布局方式如何在社交网站上做视频推广方案
  • 惠城网站建设服务做1688网站需要懂英语吗
  • 请人做网站要多少钱搜索引擎优化概述
  • 郑州中森网站建设免费网站app生成软件
  • 做诚信通网站seo新手快速入门
  • 做网站怎么去找客户带会员中心WordPress免费主题
  • 网站建设资费安平县护栏网站建设
  • 做视频网站侵权吗个体户网站备案
  • 苏州姑苏区建设局网站智慧团建登录官网手机版
  • 如何搭建一个视频网站广告制作方案
  • 网站策划ps苏州建站公司速找苏州聚尚网络
  • 网站备案 关闭客户制作网站时的问题
  • 项目网站分析推荐做ppt照片的网站
  • wordpress注明网站网站建设需要什么手续
  • 厦门过路费网站福建省建设执业资格注册中心网站
  • c 网站开发案例详解手机网站返回顶部代码
  • 济南微网站建设图书馆评估定级关于网站建设标准