怎么弄网站做网站卖东西wordpress 怎样写函数
news/
2025/9/24 8:36:34/
文章来源:
怎么弄网站做网站卖东西,wordpress 怎样写函数,百度怎么发布网站,wordpress微博登陆插件在Android开发中使用View制作一个引导动画发布时间#xff1a;2020-11-20 16:46:16来源#xff1a;亿速云阅读#xff1a;98作者#xff1a;Leah这篇文章将为大家详细讲解有关在Android开发中使用View制作一个引导动画#xff0c;文章内容质量较高#xff0c;因此小编分享…在Android开发中使用View制作一个引导动画发布时间2020-11-20 16:46:16来源亿速云阅读98作者Leah这篇文章将为大家详细讲解有关在Android开发中使用View制作一个引导动画文章内容质量较高因此小编分享给大家做个参考希望大家阅读完这篇文章后对相关知识有一定的了解。一、实现效果图关于贝塞尔曲线二、实现代码1.自定义viewpackage com.czhappy.showintroduce.view;import android.content.Context;import android.graphics.Bitmap;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.graphics.Path;import android.util.AttributeSet;import android.view.View;import android.widget.RelativeLayout;/*** Description: 水波纹动画引导view* User: chenzheng* Date: 2017/1/14 0014* Time: 18:01*/public class RippleIntroView extends RelativeLayout implements Runnable {private int mMaxRadius 70;private int mInterval 20;private int count 0;private Bitmap mCacheBitmap;private Paint mRipplePaint;private Paint mCirclePaint;private Path mArcPath;public RippleIntroView(Context context) {this(context, null);}public RippleIntroView(Context context, AttributeSet attrs) {this(context, attrs, 0);}public RippleIntroView(Context context, AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);init();}private void init() {mRipplePaint new Paint();mRipplePaint.setAntiAlias(true);mRipplePaint.setStyle(Paint.Style.STROKE);mRipplePaint.setColor(Color.WHITE);mRipplePaint.setStrokeWidth(2.f);mCirclePaint new Paint();mCirclePaint.setAntiAlias(true);mCirclePaint.setStyle(Paint.Style.FILL);mCirclePaint.setColor(Color.WHITE);mArcPath new Path();}/*** view大小变化时系统调用* param w* param h* param oldw* param oldh*/Overrideprotected void onSizeChanged(int w, int h, int oldw, int oldh) {super.onSizeChanged(w, h, oldw, oldh);if (mCacheBitmap ! null) {mCacheBitmap.recycle();mCacheBitmap null;}}Overrideprotected void onDraw(Canvas canvas) {//获取加号图片viewView mPlusChild getChildAt(0);//获取提示图片viewView mRefsChild getChildAt(1);if (mPlusChild null || mRefsChild null) return;//获取加号图片大小final int pw mPlusChild.getWidth();final int ph mPlusChild.getHeight();//获取提示图片大小final int fw mRefsChild.getWidth();final int fh mRefsChild.getHeight();if (pw 0 || ph 0) return;//加号图片中心点坐标final float px mPlusChild.getX() pw / 2;final float py mPlusChild.getY() ph / 2;//提示图片左上角坐标final float fx mRefsChild.getX();final float fy mRefsChild.getY();final int rw pw / 2;final int rh ph / 2;if (mCacheBitmap null) {mCacheBitmap Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);Canvas cv new Canvas(mCacheBitmap);super.onDraw(cv);//清空所有已经画过的path至原始状态mArcPath.reset();//起始轮廓点移至xy坐标点,即加号图片正下方再往下20位置mArcPath.moveTo(px, py rh mInterval);//设置二次贝塞尔实现平滑曲线前两个参数为操作点坐标后两个参数为结束点坐标mArcPath.quadTo(px, fy - mInterval, fx fw * 0.618f, fy - mInterval);//0~255数值越小越透明mRipplePaint.setAlpha(255);cv.drawPath(mArcPath, mRipplePaint);//绘制半径为6的实心圆点cv.drawCircle(px, py rh mInterval, 6, mCirclePaint);}//绘制背景图片canvas.drawBitmap(mCacheBitmap, 0, 0, mCirclePaint);//保存画布当前的状态int save canvas.save();for (int step count; step mMaxRadius; step mInterval) {//step越大越靠外就越透明mRipplePaint.setAlpha(255 * (mMaxRadius - step) / mMaxRadius);canvas.drawCircle(px, py, (float) (rw step), mRipplePaint);}//恢复Canvas的状态canvas.restoreToCount(save);//延迟80毫秒后开始运行postDelayed(this, 80);}Overridepublic void run() {//把run对象的引用从队列里拿出来这样他就不会执行了但 run 没有销毁removeCallbacks(this);count 2;count % mInterval;invalidate();//重绘}/*** 销毁view时调用收尾工作*/Overrideprotected void onDetachedFromWindow() {super.onDetachedFromWindow();if (mCacheBitmap ! null) {mCacheBitmap.recycle();mCacheBitmap null;}}}2.MainActivity.javapackage com.czhappy.showintroduce.activity;import android.os.Bundle;import android.support.v7.app.AppCompatActivity;import android.view.View;import android.view.ViewGroup;import com.czhappy.showintroduce.R;public class MainActivity extends AppCompatActivity {Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);View view findViewById(R.id.layout_ripple);view.setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {((ViewGroup) v.getParent()).removeView(v);}});}}3.activity_main.xmlandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:textHello World! /android:idid/layout_rippleandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:clickabletrueandroid:fitsSystemWindowstrueandroid:background#AA000000android:idid/iv_plusandroid:layout_marginTop36dpandroid:srcmipmap/ic_addandroid:layout_alignParentRighttrueandroid:layout_marginRight6dpandroid:layout_widthwrap_contentandroid:layout_heightwrap_content/android:srcmipmap/tips_subscribeandroid:idid/tv_titleandroid:layout_belowid/iv_plusandroid:layout_marginTop50dpandroid:layout_alignParentRighttrueandroid:layout_marginRight40dpandroid:layout_widthwrap_contentandroid:layout_heightwrap_content/关于在Android开发中使用View制作一个引导动画就分享到这里了希望以上内容可以对大家有一定的帮助可以学到更多知识。如果觉得文章不错可以把它分享出去让更多的人看到。
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/915366.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!