我在活動中有多個垂直對齊的按鈕(一個在另一個之下),我希望這些按鈕出現在屏幕上,就好像用戶看到它來自屏幕外部一樣(在X軸上)。我經歷了很多例子,但找不到真正的解決方案。如果您可以提供鏈接或示例,那就太棒了。早些時候,我使用翻譯,但按鈕從其真實位置移動到外部並返回到其原始位置。我的要求是隻需要將這些按鈕從屏幕外部移動到原始位置。將按鈕從活動外部移動到特定位置
片段中的主要活動:
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
button4 = (Button) findViewById(R.id.button4);
buttonAnimation = AnimationUtils.loadAnimation(this,
R.anim.button_animation);
button1.setAnimation(buttonAnimation);
button2.setAnimation(buttonAnimation);
button3.setAnimation(buttonAnimation);
button4.setAnimation(buttonAnimation);
RES /動畫/ button_animation.xml:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0"
android:toXDelta="100%p"
android:duration="500"
android:repeatCount="1"
android:repeatMode="reverse" >
</translate>
</set>
在該代碼中,該按鈕被外出屏幕的和未來的其原始位置。我需要讓這隻來自外部的其真實的位置。基本上,我不確定什麼是最好的方法來做到這一點。
我的意思是......他爲什麼......請大家幫個忙,讓他們看看你寫的代碼,失敗的代碼,你認爲失敗的地方,你已經做了什麼努力使它工作,之後發生了什麼,以及是什麼促使你問「互聯網」爲你編寫這段代碼......免費,讓我告訴你,如果你使用AnimatorSets等,你可能需要確保轉換(在你的翻譯案例)*在動畫結束後停留*。無論如何...發佈你的代碼或者你不會得到很多幫助:/ –