
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中平滑淡出图像视图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)