我正面臨一個相當有趣但令人討厭的錯誤,在我的線性佈局中,我隱藏了另一個使用負值的邊界線性佈局,當用戶從列表中選擇一種類型時,我使用Translational Animation將佈局帶到前端,錯誤在於佈局前面有一個編輯文本變成死了,當我滾動(我的主要佈局是由滾動視圖包圍)它來活着,當我停止滾動它變得死了再次...我真的不能判斷爲什麼會發生這樣的傢伙PLZ幫助....EditText在動畫和動態回滾滾動後卡住......?
我也粘貼下面顯示我的應用程序的這種令人討厭的行爲視頻的鏈接
http://www.dailymotion.com/video/xlskk8_android-app-edit-text-error_tech
滾動視圖裏面我的佈局XML是
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="-110dip"
android:layout_marginBottom="5dip"
android:id="@+id/notes_editor"
android:orientation="vertical"
>
<EditText
android:id="@+id/enter_note"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:maxLines="2"
android:lines="2">
</EditText>
<Button
android:id="@+id/save_note"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Save" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-10dip"
android:id="@+id/notes_list"
android:orientation="vertical"
>
</LinearLayout>
</LinearLayout>
下面的按鈕空的線性佈局用於動態添加子視圖所有其他的事情都是正確執行其功能,僅表示該異常行爲的編輯文本。
用於動畫的代碼如下
public void animateEditor()
{
slider = new TranslateAnimation(0, 0, 0,180);
slider.setDuration(1250);
slider.setFillAfter(true);
notes_list.startAnimation(slider);
notes_editor.startAnimation(slider);
}
我正在拖動和拖放我想維持該動畫,直到行動下來被稱爲,但設置fillafter是假的,它會立即回來,你可以幫助嗎? –
正如我所描述的,您必須爲您的動畫使用動畫偵聽器,其中onAnimationEnd(Animation a)方法將在動畫結束時調用,並且當時您應該將視圖放置到應該在動畫之後的新位置。 SetFillAfter(true)意味着只在動畫結束時保留視圖圖像,而不是動畫中的視圖的正常圖像,而不是具有完整功能的視圖,因此fillafter會將視圖圖像放置到新的位置,而不是其視圖的圖像觸摸邊界 –
這幾乎爲我工作,但仍然偶爾閃爍,特別是在較舊的Android操作系統。我發現通過延遲佈局更新解決了問題。即使用layout.post(Runnable)構造。 –