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. 移動圖像從左到右
- 3. 如何移動/從左邊的圖像滑動到右側
- 4. 如何從左/右移動到下一個ViewController從左到右
- 5. 如何在jQuery中將圖像從左向右移動?
- 6. 如何從左到右和從右到左動畫背景圖像
- 7. Android viewPager圖像從右向左滑動
- 8. 動畫圖像從左到右滾動
- 9. 如何讓圖像從左側0,0位置向右側移動到右側?
- 10. 從左到右滑動圖像
- 11. 如何連續將圖像/ div從右向左移動?
- 12. 動畫圖像像它從右向左移動
- 13. Android:從左到右從左到右滑動
- 14. 如何從左至右一個一個地動畫圖像android
- 15. 如何讓我的文本從右到左在PHP中移動?
- 16. android-webview左右移動/平移/滾動
- 17. 從左側屏幕外部移動圖像到右側屏幕外部Android
- 18. 在UIScrollView中左右移動
- 19. 動畫或從右向左移動圖像
- 20. 如何從右到左在android的ActionBar中的活動標籤?
- 21. 從左到右移動UITableView項目
- 22. PictureBox反覆從左到右移動
- 23. c#從右到左移動標籤
- 24. 讓圖像從右到左在NSImageView中點擊流動
- 25. 將光標懸停在圖像上時,如何使圖像左右移動?
- 26. 如何左右移動圖像在前面或後面圖像Jquery
- 27. 如何裁剪圖像左,右僅適用於移動設備
- 28. CSS3動畫從左向右移動,然後繼續從外部移動到左
- 29. 如何使用Swift將自定義視圖右至左右左右移動
- 30. 如何在網頁加載時從右向左滾動圖像?
喜..謝謝你的答覆。我試着用你的上面的例子。但它只顯示單詞「動畫」沒有任何舉動。 – sanjay 2011-01-14 10:46:54