首页 新闻 会员 周边

listview 动画移动的问题

0
悬赏园豆:160 [已关闭问题] 关闭于 2012-04-02 14:54

初始状态截图(全屏幕,没截状态栏):

加了TranslateAnimation运行后的效果(listview底部移动上去了):

 

代码如下:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.text);

listview = (ListView) findViewById(R.id.listview1);
this.setData();

SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.item,
new String[] { "textview" }, new int[] { R.id.textview1 });
listview.setAdapter(adapter);

new Async().execute();

}

class Async extends AsyncTask<Void, Integer, Void> {
@Override
protected Void doInBackground(Void... params) {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
this.publishProgress(0);
return null;
}

@Override
protected void onProgressUpdate(Integer... values) {
anim();//5秒后执行动画
super.onProgressUpdate(values);
}
}

private void anim() {

TranslateAnimation anim = new TranslateAnimation(0, 0, 0, -100);
anim.setDuration(5000);
anim.setInterpolator(new LinearInterpolator());
anim.setFillAfter(true);
listview.startAnimation(anim);

}

 

在动画移动的时候,listview的底部就慢慢向上移动,这个是啥问题啊?

谢谢各位了!

当年明月的主页 当年明月 | 初学一级 | 园豆:10
提问于:2012-03-28 01:23
< >
分享
所有回答(4)
0

学习。。。

KivenRo | 园豆:1734 (小虾三级) | 2012-03-28 09:00
0

你在这里设置了动画的持续时间

anim.setDuration(5000);
把这个时间改短点看看
az235 | 园豆:8483 (大侠五级) | 2012-03-28 10:08

呵呵,改短点也一样的

支持(0) 反对(0) 当年明月 | 园豆:10 (初学一级) | 2012-03-28 14:08
0

你现在是滚动的是Listview,其实你想滚动listview中的内容。所以listview后面的背景就会出来了。

Lee's Blog | 园豆:530 (小虾三级) | 2012-03-28 13:32

对啊, 请问怎么实现呢,谢谢 

支持(0) 反对(0) 当年明月 | 园豆:10 (初学一级) | 2012-03-28 14:09

@我说_小莫: 不知道你是不是写的wpf,ListView设置它的长度方向 VerticalAlignment="Stretch"

或者把背景设置成listview一样的颜色。或者ListView外面套个ScrollViewer。你试试

支持(0) 反对(0) Lee's Blog | 园豆:530 (小虾三级) | 2012-03-28 15:56

@Lee's Blog: ...不好意思,没说清楚,是android!  没有那个属性

支持(0) 反对(0) 当年明月 | 园豆:10 (初学一级) | 2012-03-28 20:26

@我说_小莫: android我不清楚 你可以试试ListView外面套个ScrollViewer。scrollviewer固定

支持(0) 反对(0) Lee's Blog | 园豆:530 (小虾三级) | 2012-03-28 21:14
0

试试这个:

android:fadingEdge="none" 
Fight+ | 园豆:211 (菜鸟二级) | 2012-03-28 18:12

这是设置阴影消失的 

支持(0) 反对(0) 当年明月 | 园豆:10 (初学一级) | 2012-03-28 20:27
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册