我有一个视图(sendSidePanel),在呈现视图时我会隐藏它:
public void setListnerToRootView(){
final View activityRootView = getWindow().getDecorView().findViewById(android.R.id.content);
final RelativeLayout sendSlidePanelFinal = (RelativeLayout)findViewById(R.id.sendSlidePanel);
final ViewTreeObserver observer = activityRootView.getViewTreeObserver();
observer.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
ViewHelper.setTranslationY(sendSlidePanel, sendSlidePanelFinal.getHeight());
}
});
}
我他们使用 ObjectAnimator 在按钮按下时上下动画视图:
if(panelDown){
ObjectAnimator anim = ObjectAnimator.ofFloat(sendSlidePanel, "translationY", 0);
panelDown=false;
}
else{
ObjectAnimator anim = ObjectAnimator.ofFloat(sendSlidePanel, "translationY", chatPanel.getHeight());
panelDown=true;
}
问题是,当我想向下动画面板(又名 panelDown==false)时,在动画向下动画之前,视图(sendSlidePanel)会有轻微的闪烁。
但是,我确实尝试过,一开始没有隐藏视图,而是在单击按钮时将其动画化。在这种情况下不会发生闪烁。似乎只有在初始动画之后才会发生闪烁。
我什至尝试过,但无济于事:
public void onAnimationEnd(Animator arg0) {
//Attempt to get rid of flicker
sendSlidePanel.clearAnimation();
sendSlidePanel.requestLayout();
}
即使这样,但无济于事: Android Animation Flicker
请帮忙,谢谢!