androidview动画发光效果在imageview上

androidview动画发光效果在imageview上,第1张

概述我正在开发一个应用程序,在我的主页上,我需要给徽标(imageview)提供发光和褪色效果动画我尝试了很多,但是找不到如何给出发光效果动画,我知道onclick事件的发光效果请帮我解决这个问题 提前致谢 public class CustomView extends ImageView{public CustomView(Context context, AttributeSet attrs, 我正在开发一个应用程序,在我的主页上,我需要给徽标(imagevIEw)提供发光和褪色效果动画我尝试了很多,但是找不到如何给出发光效果动画,我知道onclick事件的发光效果请帮我解决这个问题
提前致谢
public class CustomVIEw extends ImageVIEw{public CustomVIEw(Context context,AttributeSet attrs,int defStyle) {    super(context,attrs,defStyle);}public CustomVIEw(Context context,AttributeSet attrs) {    super(context,attrs);}public CustomVIEw(Context context) {    super(context);}boolean drawGlow = false;//this is the pixel coordinates of the screenfloat glowX = 0;float glowY = 0;//this is the radius of the circle we are drawingfloat radius = 20;//this is the paint object which specifIEs the color and Alpha level //of the circle we drawPaint paint = new Paint();{    paint.setAntiAlias(true);    paint.setcolor(color.WHITE);    paint.setAlpha(50);};@OverrIDepublic voID draw(Canvas canvas){    super.draw(canvas);    if(drawGlow)        canvas.drawCircle(glowX,glowY,radius,paint);}@OverrIDepublic boolean ontouchEvent(MotionEvent event){    if(event.getAction() == MotionEvent.ACTION_DOWN){        drawGlow = true;    }else if(event.getAction() == MotionEvent.ACTION_UP)        drawGlow = false;    glowX = event.getX();    glowY = event.getY();    this.invalIDate();    return true;}}

这段代码是我希望动画的触摸事件

解决方法 对于发光效果检查 Glow effect和

对于闪烁类型的动画使用它,你必须改变Reapeatcount和持续时间根据您的要求

AlphaAnimation  b@R_419_6862@animation= new AlphaAnimation(1,0); // Change Alpha from fully visible to invisibleb@R_419_6862@animation.setDuration(300); // duration - half a secondb@R_419_6862@animation.setInterpolator(new linearInterpolator()); // do not alter animation rateb@R_419_6862@animation.setRepeatCount(3); // Repeat animation infinitelyb@R_419_6862@animation.setRepeatMode(Animation.REVERSE);

使用后如下所示

imagevIEw.startAnimation(b@R_419_6862@animation);  or imagevIEw.setAnimation(b@R_419_6862@animation);
总结

以上是内存溢出为你收集整理的androidview动画发光效果在imageview上全部内容,希望文章能够帮你解决androidview动画发光效果在imageview上所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1134620.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存