簡體   English   中英

Android TranslateAnimation無法正常工作

[英]Android TranslateAnimation Not working

我已經嘗試並試圖弄清楚這一點,但是我似乎無法讓TranslateAnimation正常工作。 無需在屏幕上滑動我的視圖,而是將其從A點傳送到B點。

這是我在此示例中要嘗試的操作:單擊按鈕時,將其滑到右側。

這是發生的情況:它滯后了片刻,然后只是傳送而不是滑動。

這是我的代碼:

  <ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/button"
    android:layout_centerHorizontal="true"
    android:layout_below="@+id/anchor"
    android:paddingTop="10dp"
    android:onClick="AnimateButton"
    android:id="@+id/Button"/>

以及相應的Java代碼:

    public void AnimateButton(View view)
{
    View playButton = (ImageView) findViewById(R.id.Button);

    TranslateAnimation ButtonAnimation = new TranslateAnimation(0, 100, 0, 100);
    ButtonAnimation.setDuration(2000);
    ButtonAnimation.setFillEnabled(true);
    ButtonAnimation.setFillBefore(true);
    Button.startAnimation(ButtonAnimation);
}

我已經嘗試過,並且將fillAfter設置為false,並在具有相同故事的XML中創建了自己的動畫(傳送而不是滑動)。

有人可以幫我解決這個問題嗎? 如果有更好的方式滑動視圖,而我做的效率很低,請告訴我。 謝謝!

PS:關於該主題,我幾乎閱讀了所有其他stackoverflow帖子,到目前為止,它們都沒有起作用,但是我仍在搜索中,所以請不要僅僅將我鏈接到另一個與此主題相似的問題。

實際上,我只是想通了。 由於某種原因,它在我的手機上無法正常工作,但是我在另一部手機上嘗試了它,效果很好。 我正在運行4.4.4,另一部手機是4.3(三星和Verizon,雖然我真的不知道這有多大區別,但我知道他們對操作系統做了些微調整,所以我想我把它扔了出去) )。 我的手機是銀河筆記4邊緣,而它可以工作的手機是銀河筆記3(再說一次,可能沒有什么區別,但我想我會在那邊解決)。

我將報告此問題,因此希望可以盡快解決。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM