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