开发者

Android View animation and AsyncTask

开发者 https://www.devze.com 2023-02-13 09:28 出处:网络
I have my horizontal main menu and I want it to move the clicked item to the center. On click event inside HorizontalScrollView I have something like this

I have my horizontal main menu and I want it to move the clicked item to the center. On click event inside HorizontalScrollView I have something like this

int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
final int pos = v.getLeft() - (screenWidth/2 - v.getWidth()/2);
final HorizontalScrollView hsv = (HorizontalScrollView)findViewById(R.id.my_scrollview);
hsv.setSmoothScrollingEnabled(true);
hsv.smoothScrollTo(pos, 0);

//my asyncTask to load list of headlines
new LoadLocalHeadlinesTask().execute();

Everything works fine except that onPostEx开发者_如何转开发ecute() method (which updates listView with new items) is called before the 'smooth' animation of the HorizontalScrollView is finished. Because of that the animation is not smooth at all.

Could you help me with this, maybe you know different approach?

Thanks

0

精彩评论

暂无评论...
验证码 换一张
取 消