22
A
回答
56
ll = new LinearLayout(this);
ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
ll.setOrientation(LinearLayout.VERTICAL);
tv = new TextView(this);
tv.setText("Animation");
moveLefttoRight = new TranslateAnimation(0, 200, 0, 0);
moveLefttoRight.setDuration(1000);
moveLefttoRight.setFillAfter(true);
button = new Button(this);
button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
button.setText("PressMe");
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
tv.startAnimation(moveLefttoRight);
}
});
ll.addView(tv);
ll.addView(button);
setContentView(ll);
是这样做的一种方式。
29
移动图像从左至右,从右至左通过采用Android TranslateAnimation
ImageView img_animation = (ImageView) findViewById(R.id.img_animation);
TranslateAnimation animation = new TranslateAnimation(0.0f, 400.0f,
0.0f, 0.0f); // new TranslateAnimation(xFrom,xTo, yFrom,yTo)
animation.setDuration(5000); // animation duration
animation.setRepeatCount(5); // animation repeat count
animation.setRepeatMode(2); // repeat animation (left to right, right to left)
//animation.setFillAfter(true);
img_animation.startAnimation(animation); // start animation
-1
添加该代码R.anim文件夹
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<translate
android:fromXDelta="0%p"
android:toXDelta="100%p"
android:duration="800" />
</set>
相关问题
- 1. 如何在Android中将图像从左到右从右向左移动?
- 2. 图像在android中从左到右从右至左滑动?
- 3. 如何在Swift中将图像视图从左到右移动
- 4. 如何在Android中将图像从左向右移动?
- 5. 移动图像从左到右
- 6. 移动图像从左到右javascript
- 7. 如何移动/从左边的图像滑动到右侧
- 8. 如何从左/右移动到下一个ViewController从左到右
- 9. 如何在jQuery中将图像从左向右移动?
- 10. 左右滑动图像android
- 11. 如何将图像从左到右或从右到左滑动使用jquery?
- 12. 如何从左到右和从右到左动画背景图像
- 13. 动画图像从左到右滚动
- 14. Android viewPager图像从右向左滑动
- 15. iOS:autolayout从左到右移动视图
- 16. Android碎片拖动或移动从左到右或从右到左
- 17. 如何让图像从左侧0,0位置向右侧移动到右侧?
- 18. 在android中的布局中自动从右向左移动图像
- 19. 无限图像滚动从右到左
- 20. 从左到右滑动图像
- 21. 如何将图像从左向右移动?
- 22. 如何连续将图像/ div从右向左移动?
- 23. 如何让图像从右向左水平移动浏览器?
- 24. android动画从右到左
- 25. 如何让文字在Android中从左向右移动?
- 26. 动画图像像它从右向左移动
- 27. 使用ObjectAnimation从左到右移动图像
- 28. 当我点击按钮时如何设置动画在android中从左到右和从右到左移动图像?
- 29. 在外圈内左右移动图像android
- 30. Android:从左到右从左到右滑动
喜..谢谢你的答复。我试着用你的上面的例子。但它只显示单词“动画”没有任何举动。 – sanjay 2011-01-14 10:46:54