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

酒店网站建设的需求分析报告logo设计在线生成免费标智客

酒店网站建设的需求分析报告,logo设计在线生成免费标智客,西安软件公司有哪些,上海纯设计公司排名Android实现漂亮的波纹动画 本文章讲述如何使用二维画布canvas和camera、矩阵实现二、三维波纹动画效果(波纹大小变化、画笔透明度变化、画笔粗细变化) 一、UI界面 界面主要分为三部分 第一部分:输入框,根据输入x轴、Y轴、Z轴倾…

Android实现漂亮的波纹动画

本文章讲述如何使用二维画布canvas和camera、矩阵实现二、三维波纹动画效果(波纹大小变化、画笔透明度变化、画笔粗细变化)

一、UI界面

界面主要分为三部分
第一部分:输入框,根据输入x轴、Y轴、Z轴倾斜角度绘制波纹动画立体效果
第二部分:点击按钮PLAY:开始绘制动画;点击按钮STOP:停止绘制动画
第三部分:绘制波纹动画的自定义view
在这里插入图片描述
activity_main.xml实现如下:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:padding="16dp"android:gravity="center"android:orientation="vertical"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:layout_marginBottom="8dp"><LinearLayoutandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:orientation="vertical"android:gravity="center_horizontal"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="X轴倾斜" /><EditTextandroid:id="@+id/editText_X"android:layout_width="match_parent"android:layout_height="wrap_content"android:inputType="number"android:text="0"/></LinearLayout><LinearLayoutandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:orientation="vertical"android:gravity="center_horizontal"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Y轴倾斜" /><EditTextandroid:id="@+id/editText_Y"android:layout_width="match_parent"android:layout_height="wrap_content"android:inputType="number"android:text="0"/></LinearLayout><LinearLayoutandroid:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:orientation="vertical"android:gravity="center_horizontal"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Z轴倾斜" /><EditTextandroid:id="@+id/editText_Z"android:layout_width="match_parent"android:layout_height="wrap_content"android:inputType="number"android:text="0"/></LinearLayout></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:gravity="center"android:paddingTop="16dp"><Buttonandroid:id="@+id/playButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Play"android:layout_marginEnd="8dp"/><Buttonandroid:id="@+id/stopButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Stop"android:layout_marginEnd="8dp"/></LinearLayout><FrameLayoutandroid:layout_width="match_parent"android:layout_height="0dp"android:layout_weight="1"android:layout_gravity="center"><!-- WaveView --><com.example.waveanimationbysingleview.animation.WaveViewandroid:id="@+id/wave_view"android:layout_width="match_parent"android:layout_height="606dp"android:layout_gravity="center" /></FrameLayout></LinearLayout>

二、自定义view实现

新建一个WaveView类继承自View,声明类成员变量和实现构造函数初始化

public class WaveView extends View{private RippleAnimationInfo mRippleInfo;//动画属性类,包括最大、最小半径,光圈等private final Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);private float centerX, centerY; //绘制画布中心点private float[] mRadiusArray;  // 存储当前绘制每圈光波的半径private float[] mAlphaArray;   //存储当前绘制每圈光波的透明度private float[] mStrokenArray; //存储当前绘制每圈光波的画笔宽度private final Camera mCamera = new Camera();//相机private final Matrix mMatrix = new Matrix();//矩阵private final RectF mRectF = new RectF();private Boolean mIsDrawing = false;//是否绘制标志位private Bitmap mLogoBitmap;//中心点表情😝logoprivate AnimatorSet mAnimatorSet = new AnimatorSet();//多动画组合类private List<Animator> mAnimatorList = new ArrayList<>();//存储动画列表public WaveView(Context context) {super(context);init();}public WaveView(Context context, AttributeSet attrs) {super(context, attrs);init();}public WaveView(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);init();}

构造函数初始化

添加动画

  1. 圆圈等比变大动画
  2. 透明度渐变动画
  3. 画笔由细变粗动画
private void initAnimation() {int rippleDelay = mRippleInfo.durationTime/mRippleInfo.rippleCount;for (int i = 0; i < mRippleInfo.rippleCount; i++) {//动画1-半径变大final int index = i;ValueAnimator radiusAnimator = ValueAnimator.ofFloat(mRippleInfo.minRadius, mRippleInfo.maxRadius);radiusAnimator.setDuration(mRippleInfo.durationTime); // 动画持续时间radiusAnimator.setStartDelay(i * rippleDelay); // 延迟启动radiusAnimator.setRepeatCount(ValueAnimator.INFINITE);radiusAnimator.setRepeatMode(ValueAnimator.RESTART);radiusAnimator.addUpdateListener(animation -> {mRadiusArray[index] = (float) animation.getAnimatedValue();invalidate(); // 重绘视图});//动画2-画笔变粗ValueAnimator strokeAnimator = ObjectAnimator.ofFloat(mRippleInfo.minStrokenWidth, mRippleInfo.maxStrokenWidth);strokeAnimator.setDuration(mRippleInfo.durationTime); // 动画持续时间strokeAnimator.setStartDelay(i * rippleDelay); // 延迟启动strokeAnimator.setRepeatCount(ValueAnimator.INFINITE);strokeAnimator.setRepeatMode(ValueAnimator.RESTART);strokeAnimator.addUpdateListener(animation -> {mStrokenArray[index] = (float) animation.getAnimatedValue();invalidate(); // 重绘视图});//动画3-颜色淡出ValueAnimator alphaAnimator = ObjectAnimator.ofFloat( 0.1f, 0.8f, 0.8f,0.4f, 0);alphaAnimator.setDuration(mRippleInfo.durationTime); // 动画持续时间alphaAnimator.setStartDelay(i * rippleDelay); // 延迟启动alphaAnimator.setRepeatCount(ValueAnimator.INFINITE);alphaAnimator.setRepeatMode(ValueAnimator.RESTART);alphaAnimator.addUpdateListener(animation -> {mAlphaArray[index] = (float) animation.getAnimatedValue();invalidate(); // 重绘视图});mAnimatorList.add(radiusAnimator);mAnimatorList.add(strokeAnimator);mAnimatorList.add(alphaAnimator);}mAnimatorSet.playTogether(mAnimatorList);}

应用矩阵变换

重写ondraw

@Overrideprotected void onDraw(Canvas canvas) {super.onDraw(canvas);if (!mIsDrawing){return;}canvas.save();// 计算中心点centerX = getWidth() / 2.0f;centerY = getHeight() / 2.0f;canvas.concat(mMatrix);// 将矩阵应用到画布上//绘制多圈波纹for (int i = 0; i < mRippleInfo.rippleCount; i++) {if (mRadiusArray[i] > 0) {paint.setStrokeWidth(mStrokenArray[i]);paint.setAlpha((int)(255 * mAlphaArray[i]));canvas.drawCircle(centerX, centerY,mRadiusArray[i],paint);}}// 中心点绘制 logocanvas.drawBitmap(mLogoBitmap, (getWidth()- mRippleInfo.minRadius)/2, (getHeight()- mRippleInfo.minRadius)/2, null);canvas.restore();}

二、二维波纹动画

waveAnimation_2D

三、三维波纹动画

waveAnimation_3D


文章转载自:

http://LVQS1Du3.qdxtj.cn
http://eTw1gtj9.qdxtj.cn
http://UBA5Sl0N.qdxtj.cn
http://6SuFtWbc.qdxtj.cn
http://TdKfvfL3.qdxtj.cn
http://fKYRkQ77.qdxtj.cn
http://Bqp2ceQb.qdxtj.cn
http://nc0p9CQD.qdxtj.cn
http://LLJd4voA.qdxtj.cn
http://Q7Xjnrn8.qdxtj.cn
http://Ap9VGxQ2.qdxtj.cn
http://wo6YwRUd.qdxtj.cn
http://2Nt7wEMc.qdxtj.cn
http://Lmc4HqKs.qdxtj.cn
http://Y5Joxc6s.qdxtj.cn
http://ELHw7itM.qdxtj.cn
http://CXYAcbFs.qdxtj.cn
http://810izqb0.qdxtj.cn
http://u8NIHhem.qdxtj.cn
http://zyRZZJ3W.qdxtj.cn
http://SQ3AqDqb.qdxtj.cn
http://sc7BXCvk.qdxtj.cn
http://gE4zMNdv.qdxtj.cn
http://yqwXV0mQ.qdxtj.cn
http://bp3gS44f.qdxtj.cn
http://GeuCMYbp.qdxtj.cn
http://IotAjOZ4.qdxtj.cn
http://YTrVWpLD.qdxtj.cn
http://P3ZV02C1.qdxtj.cn
http://Yaf87koc.qdxtj.cn
http://www.dtcms.com/wzjs/706471.html

相关文章:

  • 网站建设0基础深入浅出php
  • h5开源网站模板建购物网站如何运营
  • 黄金网站软件app视频app运营
  • 网站建设公司华网天下公司wap网站开发联系电话
  • 建设国际网站第一模板ppt网
  • 上海知名网站开发公司网站建设税率多少
  • 自己如何建企业网站省技能大赛网站开发方案
  • 免费制作软件的网站淘宝页面设计的网站
  • 网站建设找谁重庆网站建设公司招聘
  • 网站甚而模板镇江百姓网
  • 构建微网站沧州商城网站开发设计
  • 深圳专业企业网站建设模板赣州网页设计师培训
  • 大兴企业网站建设公司时彩网站开发
  • 网站制作公司运作方案wordpress 手机lianxu播放
  • 成都营销型网站建设公司亦庄网站设计
  • dw建设网站如何加入音乐网站建设与管理指什么
  • 计算机网络技术 网站建设方向网站开发行业知识新闻
  • 宜城营销型网站套餐网站的建设与运营模式
  • 做网站的相关协议绵阳专门做网站的公司
  • 叮当设计网站动易网站无法安装
  • 福州网站开发培训赣州seo培训
  • 山西省消防总队建设工程备案网站惠州模板网站建设
  • 湖南郴州市汝城县win10系统优化软件哪个好
  • 保定网站seo企业做网站的公司
  • 男的女的做那个视频网站wordpress 的模板
  • 2015做哪个网站能致富滕州网站建设助企网络
  • 网站开发与维护介绍好的买手表网站
  • 网站架构分析教育海报设计素材网站
  • 网站页面设计的重要性乐东黎族自治县住房建设局网站
  • wordpress获取文章内容过滤空格四川大学网站seo诊断报告