我們可以讓一個組件動起來,也可以讓幾個組件一起動起來,其實就是給五大布局設定動畫即可。
那麼,如何給Linearlayout等布局設定絢麗的動畫呢?
首先,要使用一個類,LayoutAnimationController。
其次,調用一個方法,layout.setLayoutAnimation(),並非是setAnimation().
實現方法有兩種,一種是在xml中的linearLayout設定android:layoutAnimation=“@anim/layoutanimation_layout”。
一種是在代碼中控制,使用LayoutAnimationController類。
第一種實現方式:
anim檔案夾中的兩個動畫檔案:
layoutanimation_layout:
layoutanimation:
第二種實現方式:
還是需要一個動畫檔案,如上,第二個檔案,layoutanimation。
java代碼:
//載入動畫Animation anim = AnimationUtils.loadAnimation(this, R.anim.list_anim);lac = new LayoutAnimationController(anim);//設定順序lac.setOrder(LayoutAnimationController.ORDER_REVERSE);//延時lac.setDelay(1);//布局設定動畫layout.setLayoutAnimation(lac);
:
<喎?http://www.bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+zai5/dXiuPbA/dfT1qTD97avu63Qp7n7yLTKx7fHs6O6xLfRxNq05qOs0OjSqtW5yr7RpMD2tcTQp7n7o6zU8tDo0qq4tNTTtcTL47eoo6xjdXC1xLi6taPSsr7N1Pa086GjPC9wPgo8cD7V4sDvyrnTw7XEysc1MTJNxNq05rXEyeixuLLiytSjrLzT1Ni2r7utuvPL+7XExNq05sq508PCytfuuN+077W9wcs4MyWjrDwvcD4KPHA+PGltZyBzcmM9"http://www.bkjia.com/uploadfile/Collfiles/20140102/2014010209553625.jpg" alt="\">
而,沒有載入動畫,單單顯示幾行資料,他的記憶體使用量率只有1%。差距是多麼的大啊。