2013-05-10 70 views

回答

9

你會想佈局視圖的XML,你會如何想它在顯示它的最後階段。然後將可見性設置消失。然後,您將創建一個TranslateAnimation

TranslateAnimation anim = new TranslateAnimation(-100f, 0f, 0f, 0f); // might need to review the docs 
anim.setDuration(1000); // set how long you want the animation 

ViewYouWantToAnimate.setAnimation(anim); 
ViewYouWantToAnimate.setVisibility(View.VISIBLE); 
+0

好吧我會在星期一嘗試這個謝謝你的建議。希望它能夠工作,並按我的需要去做。 – Shubham 2013-05-12 08:02:14

+0

非常感謝它的工作非常感謝你:-)我這樣做,其工作 – Shubham 2013-05-13 05:52:09

+1

公共無效的onClick(查看爲arg0){ \t \t \t \t如果(鍵== 0){ \t \t \t \t \t鍵= 1 ; \t \t \t \t \t TranslateAnimation anim = new TranslateAnimation(-1250f,0f,0f,0f); \t \t \t \t \t anim.setDuration(2500); \t \t \t \t \t TranslateAnimation anim1 = new TranslateAnimation(-1250f,0f,0f,0f); \t \t \t \t \t anim1.setDuration(2500); \t \t \t \t \t popup.setAnimation(anim); \t \t \t \t \t btn.setAnimation(anim1); \t \t \t \t \t popup.setVisibility(View.VISIBLE); \t \t \t \t \t btn.setBackgroundResource(R.drawable.previousnew); \t \t \t \t} – Shubham 2013-05-13 05:52:46

0

您可以使用animanion對象的setDuration()方法來調整移動速度。 He're是從我的代碼excample(它的規模擴張不動的動畫,但希望它幫助):

Animation an2 = new ScaleAnimation(TARGET_SCALE, targetXscale, TARGET_SCALE, targetYscale); 
an2.setDuration(SECOND_ANIM_LENGTH); 
+0

也許TranslateAnimation – Blackbelt 2013-05-10 13:32:32

+0

TranslateAnimation動畫=新TranslateAnimation(類型,0,類型,targetXdelta,類型,0,類型,targetYdelta); animation.setDuration(SECOND_ANIM_LENGTH); – 2013-05-10 13:36:16

+1

其實我想要抽屜點擊按鈕佈局的東西應該從左側覆蓋屏幕,然後再次點擊它應該進去的按鈕。 – Shubham 2013-05-12 07:59:00