在android中平滑淡出图像视图

在android中平滑淡出图像视图,第1张

概述我设法使imageView在10秒后消失(我的主动性的教程图像).但是我想要顺利淡出,因为这样看起来不好看,任何人都可以参考任何好的教程 img=(ImageView)findViewById(R.id.ImageTutorial); if(getIntent()!=null) { Bundle extras = getIntent().getExtras(); 我设法使imageVIEw在10秒后消失(我的主动性的教程图像).但是我想要顺利淡出,因为这样看起来不好看,任何人都可以参考任何好的教程
img=(ImageVIEw)findVIEwByID(R.ID.ImageTutorial);    if(getIntent()!=null)    {        Bundle extras = getIntent().getExtras();        String TutorialDemo=extras !=null? extras.getString("TutorialDemo"):"false";        if(TutorialDemo.equals("true"))        {            Runnable mRunnable;            Handler mHandler=new Handler();            mRunnable=new Runnable() {                        @OverrIDe                        public voID run() {                            img.setVisibility(VIEw.GONE); //This will remove the VIEw. and free s the space occupIEd by the VIEw                            }                    };                    mHandler.postDelayed(mRunnable,10*900);        }        else        {            img.setVisibility(VIEw.GONE);        }         }

这里是图像视图xml

<?xml version="1.0" enCoding="utf-8"?>  <ScrollVIEw xmlns:androID="http://schemas.androID.com/apk/res/androID"  xmlns:tools="http://schemas.androID.com/tools"  androID:layout_wIDth="match_parent" androID:layout_height="match_parent"  androID:ID="@+ID/fullvIEw"><linearLayout    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    androID:layout_margin="10dp"    androID:orIEntation="vertical" >      .      .      .      .    <ImageVIEw        androID:contentDescription="tutorial"        androID:ID="@+ID/ImageTutorial"        androID:layout_wIDth="match_parent"        androID:layout_height="120dp"        androID:layout_alignParentBottom="true"        androID:background="@drawable/tutorial"        androID:layout_margintop="40dp"        androID:gravity="center"        /></linearLayout>
解决方法 在代码中替换img.setVisibility(VIEw.GONE),调用fadeOutAndHIDeImage(img),定义如下:
private voID fadeOutAndHIDeImage(final ImageVIEw img)  {    Animation fadeOut = new AlphaAnimation(1,0);    fadeOut.setInterpolator(new AccelerateInterpolator());    fadeOut.setDuration(1000);    fadeOut.setAnimationListener(new AnimationListener()    {            public voID onAnimationEnd(Animation animation)             {                  img.setVisibility(VIEw.GONE);            }            public voID onAnimationRepeat(Animation animation) {}            public voID onAnimationStart(Animation animation) {}    });    img.startAnimation(fadeOut);}

首先应用淡出动画,然后隐藏图像视图.

总结

以上是内存溢出为你收集整理的在android中平滑淡出图像视图全部内容,希望文章能够帮你解决在android中平滑淡出图像视图所遇到的程序开发问题。

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

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

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

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

发表评论

登录后才能评论

评论列表(0条)

    保存