2016-08-18 17 views
0

我看到在xml佈局中使用這個語句會自動爲您動畫。我想它添加到我的應用程序,但是當我把它在佈局我想'android:animateLayoutChanges =「true」'還在繼續工作

<LinearLayout 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="@drawable/arrow_background" 
       android:layout_marginTop="7dp" 
       android:layout_marginBottom="7dp" 
       android:padding="10dp" 
       android:animateLayoutChanges="true" 
       android:visibility="visible" 
       android:id="@+id/format_help"> 

然後我改變能見度不見了

view.findViewById(R.id.format_help).setVisibility(View.GONE); 

它纔剛剛瞬間消失。我看到的關於這個的信息來自幾年前,所以有人知道這是否仍然有效或如何使其工作?

編輯:此外,我添加了這個聲明無處不在,它仍然無法正常工作。如果它很重要這是在片段/對話框內

回答

1

它適用於具有屬性android:animateLayoutChanges =「true」的容器內的視圖。如果線性佈局具有上述屬性,則無論何時添加或從該容器中移除新視圖,該效果都可見。容器添加或刪除時,動畫效果對容器本身不可見。有關更多信息,請查看以下鏈接。 usage of animateLayoutChanges