Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在android中平滑淡出图像视图大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我设法使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);
        }
         }@H_675_3@ 
 

这里是图像视图xml

<?xml version="1.0" encoding="utf-8"?>
  <ScrollView xmlns:android="http://scheR_560_11845@as.android.com/apk/res/android"
  xmlns:tools="http://scheR_560_11845@as.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>@H_675_3@

解决方法

代码中替换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);
}@H_675_3@ 
 

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

大佬总结

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

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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。