隐藏视图的动画,并设置能见度走了不闪屏 [英] Hide view with animation and set visibility to gone without flash the screen
本文介绍了隐藏视图的动画,并设置能见度走了不闪屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想隐藏dicelayout(dicelout在mainboardlinear),但是当动画完成后屏幕上闪过,因为View.GONE的! 如果我设置setfillafter为真实,明确的View.GONE,我没有闪光灯的问题了,但我在mainboardlinear滚动视图不能在这种情况下,滚动!
最后RelativeLayout的rLayout =(RelativeLayout的)findViewById(R.id.dicelayout);
动画动画=新TranslateAnimation(0,0,0,-rLayout.getHeight());
animation.setFillAfter(假);
animation.setFillBefore(真正的);
animation.setDuration(1000);
((的LinearLayout)findViewById(R.id.mainboardlinear))startAnimation(动画)。
线程t =新主题(新的Runnable(){
公共无效的run(){
尝试 {
视频下载(999);
runOnUiThread(新的Runnable(){
公共无效的run(){
rLayout.setVisibility(View.GONE);
}
});
}赶上(InterruptedException异常E){
// TODO自动生成的catch块
e.printStackTrace();
}
}
});
t.start();
解决方案
使用onAnimationEnd从setAnimationListener和setFillEnabled解决我的问题。
动画动漫=新TranslateAnimation(0,0,0,-rLayout.getHeight());
animation.setFillEnabled(真正的);
animation.setDuration(1000);
animation.setAnimationListener(新AnimationListener(){
@覆盖
公共无效onAnimationStart(动画动画){
// TODO自动生成方法存根
}
@覆盖
公共无效onAnimationRepeat(动画动画){
// TODO自动生成方法存根
}
@覆盖
公共无效onAnimationEnd(动画animatiofillAftern){
// TODO自动生成方法存根
// mainBoardLinear.removeView(rLayout);
rLayout.setVisibility(View.GONE);
}
});
mainBoardLinear.startAnimation(动画);
i want to hide dicelayout (dicelout was in mainboardlinear) but when animation finished the screen flashed because of View.GONE! if i set setfillafter to true and clear View.GONE, i do not have the flash problem anymore but my scrollview in mainboardlinear can't be scrolled in this case!
final RelativeLayout rLayout=(RelativeLayout)findViewById(R.id.dicelayout);
Animation animation=new TranslateAnimation(0, 0, 0, -rLayout.getHeight());
animation.setFillAfter(false);
animation.setFillBefore(true);
animation.setDuration(1000);
((LinearLayout)findViewById(R.id.mainboardlinear)).startAnimation(animation);
Thread t=new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(999);
runOnUiThread(new Runnable() {
public void run() {
rLayout.setVisibility(View.GONE);
}
});
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
t.start();
解决方案
using onAnimationEnd from setAnimationListener and setFillEnabled solve my problem.
Animation animation=new TranslateAnimation(0, 0, 0, -rLayout.getHeight());
animation.setFillEnabled(true);
animation.setDuration(1000);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animatiofillAftern) {
// TODO Auto-generated method stub
// mainBoardLinear.removeView(rLayout);
rLayout.setVisibility(View.GONE);
}
});
mainBoardLinear.startAnimation(animation);
这篇关于隐藏视图的动画,并设置能见度走了不闪屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文