正確的程序我想通過獲取其座標,然後增加或減少1他們一個動態顯示按鈕,使得按鈕可以去左邊,然後來到了正確的。如何移動按鈕向左或安卓
5
A
回答
4
使用TranslateAnimation:
TranslateAnimation animation = new TranslateAnimation(start_x, start_y, end_x, end_y);
animation.setDuration(1000); // duartion in ms
animation.setFillAfter(false);
button.startAnimation(animation);
我不知道如何可以得到它的位置,button.getTop()和button.getLeft()可以工作...
3
如果沒有把握這將幫助你,但我同樣的問題,我是能夠做到這一點使用這些方法,setTranslationX(浮動)setTranslationY(浮動)
你可以使用它像這樣
來襲這裏的Android文檔提供更多信息http://developer.android.com/reference/android/view/View.html#attr_android:translationX
0
Solution for those who are looking for left to right animation)
TranslateAnimation animation = new TranslateAnimation(0.0f, 0.0f, 0.0f, 1500.0f); // new TranslateAnimation (float fromXDelta,float toXDelta, float fromYDelta, float toYDelta)
animation.setDuration(1500); // animation duration
animation.setRepeatCount(1); // animation repeat count
animation.setFillAfter(false);
your_view .startAnimation(animation);//your_view for mine is imageView
Solution for those who are looking for repeated animation(for eg. left to right and right to left)
TranslateAnimation animation = new TranslateAnimation(0.0f, 0.0f, 0.0f, 1500.0f); // new TranslateAnimation (float fromXDelta,float toXDelta, float fromYDelta, float toYDelta)
animation.setDuration(1500); // animation duration
animation.setRepeatCount(4); // animation repeat count
animation.setRepeatMode(2); // repeat animation (left to right, right to left)
animation.setFillAfter(true);
your_view .startAnimation(animation);//your_view for mine is imageView
相關問題
- 1. 安卓移動按鈕
- 2. 向左移動jCombobox按鈕
- 3. 安卓浮動左/右按鈕
- 4. 安卓方向按鈕點擊動作
- 5. Javascript使用屏幕按鈕向左或向右移動圖像
- 6. Xamarin安卓按鈕左右邊距
- 7. 安卓:按鈕
- 8. 如何將登錄按鈕從右向左移動?
- 9. 如何在Xamarin中將按鈕從右向左移動(iOS)
- 10. 安卓:如何當按鈕被按下
- 11. 按鈕在安卓
- 12. 向左或向右移動從MATLAB
- 13. AutoHotkey按一個按鈕將光標向左移動
- 14. 如何移動圓一個div單擊按鈕時向上\向下\左\右
- 15. 如何做這些安卓按鈕
- 16. 安卓:如何點擊一個按鈕
- 17. 在按鈕懸停上向左或向右滾動圖像
- 18. 安卓移動按鈕和運行時的背景
- 19. 如何使用CoreMotion向左或向右移動精靈?
- 20. 如何在Bash中以'x'字符向右或向左移動?
- 21. 如何向左或向右移動UILabel文本?
- 22. 安卓「後退」按鈕動作
- 23. 安卓動態按鈕與setOnClickListener
- 24. 安卓滑動抽屜的按鈕
- 25. 單擊安卓按鈕動畫
- 26. 安卓佈局動作欄按鈕
- 27. 安卓圖庫動畫與按鈕
- 28. 按鈕向下移動
- 29. 將按鈕向下移動
- 30. 安卓:ImageView.ScaleType但對按鈕和/或單選按鈕
我不知道爲什麼,但button.getTop()和button.getLeft()都給出了值0 – 2012-07-06 19:31:12
謝謝@ d-32 TranslateAnimation絕對精細的按鈕正在移動。 – 2012-07-06 19:32:23
你可以把你的XML與按鈕到你的問題? – 2012-07-06 19:43:57