Android — layoutAnimation應用

1.寫一個left_in.xml方法

[html] 
<?xml version="1.0" encoding="utf-8"?> 
<translate xmlns:android="https://schemas.android.com/apk/res/android" 
    android:duration="300" 
    android:fillAfter="false" 
    android:fromXDelta="-550" 
    android:toXDelta="0" > 
</translate> 
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="https://schemas.android.com/apk/res/android"
    android:duration="300"
    android:fillAfter="false"
    android:fromXDelta="-550"
    android:toXDelta="0" >
</translate>

 

2.寫一個layoutAnimation.xml方法

[html]
<?xml version="1.0" encoding="utf-8"?> 
<layoutAnimation xmlns:android="https://schemas.android.com/apk/res/android" 
    android:animation="@anim/player_info_left_in" 
    android:animationOrder="normal" 
    android:delay="0.75" > 
 
</layoutAnimation> 
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="https://schemas.android.com/apk/res/android"
    android:animation="@anim/player_info_left_in"
    android:animationOrder="normal"
    android:delay="0.75" >

</layoutAnimation>

3.在一個擁有多行子控件的View中加載,如:

[html]
<?xml version="1.0" encoding="windows-1250"?> 
<TableLayout 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layoutAnimation="@anim/left_in_player_info_show_anim" > 
        <TableRow ………/> 
        <TableRow ………/> 
        <TableRow ………/> 
        <TableRow ………/> 
        <TableRow ………/> 
</TableLayout> 
<?xml version="1.0" encoding="windows-1250"?>
<TableLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layoutAnimation="@anim/left_in_player_info_show_anim" >
       <TableRow ………/>
        <TableRow ………/>
        <TableRow ………/>
        <TableRow ………/>
        <TableRow ………/>
</TableLayout>
4.這樣就能在打開上面xml頁面時,逐行的按<TableRow />加載動畫效果.

 

PS:Android提供的非常不錯的功能.比使用SurfaceView實現要簡單的多….

 作者:bys0201
 

 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *