我一直在搜索关于这个主题的线索,我可以在Android 2.2处理AnimationListeners时出现的闪烁中找到,但我无法解决我的问题.
我得到的是一个LinearLayout'popover',用户触摸向下移动大约100个像素,然后再触摸它以将其向上移动.我终于让它在没有任何闪烁的第一部分上工作(感谢建议在动画视图上调用clearAnimation()),但是当做相反的操作时(即,将视图向上移动),有一个闪烁开始.我无法在onAnimationStart()方法中调用clearAnimation(),因为它不会动画!
当然,如果我使用setFillAfter()而没有任何动画监听器,所有动画都能完美地工作,但是视图的触摸区域不会移动(因为视图本身没有"实际"移动).
任何帮助将不胜感激.
this.popoverTab.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
popoverTab.setClickable(false);
popoverTab.setFocusable(false);
if (popoverHidden) {
Log.d(TAG, "About to show popover");
// the popover is currently hidden, show it.
TranslateAnimation animation = new TranslateAnimation(0, 0, 100, 0);
animation.setDuration(700);
animation.setFillBefore(true);
animation.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
footer.layout(footer.getLeft(), (footer.getTop() - 100), footer.getRight(), footer.getBottom());
}
});
footer.startAnimation(animation);
} else {
Log.d(TAG, "About to hide popover");
// the …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中有一个LinearLayout,其布局高度为0.当我单击按钮时,此布局高度应为LayoutParams.WRAP_CONTENT.这是我在onclicklistner中使用的代码.
LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
slider.setLayoutParams(lp);
Run Code Online (Sandbox Code Playgroud)
我想动画这个.如何将动画设置为滑块.