我有一个 LinearLayout,其中仅包含一个 ListView。 LinearLayout 填充整个屏幕,而 listView 首先停留在屏幕的底部四分之一。 我将 ListView 的上边距设置为一个大值,以将 listView 保持在屏幕底部。下图可能会帮助您更好地理解我的布局。
现在点击按钮我希望我的listView向上滑动并填充屏幕。我正在使用翻译动画,就像这样
TranslateAnimation animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF,0.0f
,Animation.RELATIVE_TO_SELF, 0.0f
,Animation.RELATIVE_TO_SELF,0.0f
,Animation.RELATIVE_TO_SELF, -0.70f);
animation.setDuration(1000);
animation.setFillAfter(true);
animation.setFillEnabled(true);
mBottomView.startAnimation(animation);
其中 mBottomView 是我的 ListView 布局。此代码成功地将 listView 动画到顶部。
现在我的问题是,当 listView 填充屏幕时,我尝试滚动, ListView 的触摸事件在 ListView 的原始位置上方无法识别。即,当我触摸黄色空间(图像中)的任何位置来滚动 ListView 时,不会检测到触摸。我可以滚动到 listView 的原始位置下方。这是为什么?
最佳答案
我遇到了同样的问题,这个问题的答案完全定义在这个问题的答案中。 EditText stucks after animation and alive back on scrolling......?
关于安卓 : Touch events in layout after animation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9665312/