use*_*589 0 android-animation forceclose
我在menu.xml中有以下XML,它是一个我需要设置动画的LinearLayout,所以我使用了layoutAnimation属性.如果没有这个属性,布局会显示出来,但是有了这个属性集我会得到一个令人讨厌的forceclose,我不明白为什么:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bkgrnd"
android:layoutAnimation="@anim/menu_anim" <=== adding this results in FC
...etc...
Run Code Online (Sandbox Code Playgroud)
动画/ menu_anim.xml:
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<alpha
android:fromAlpha="0.0"
android:toAlpha="1.0"
android:duration="500">
</alpha>
</set>
Run Code Online (Sandbox Code Playgroud)
请帮忙!谢谢!
您无法将动画直接添加到布局中.您必须在动画文件夹中再创建一个xml文件,该文件指向动画xml(menu_anim),如下所示.
<?xml version="1.0" encoding="utf-8"?>
<layoutAnimation xmlns:android="http://schemas.android.com/apk/res/android"
android:delay="30%"
android:animation="@anim/menu_anim"
/>
Run Code Online (Sandbox Code Playgroud)
我们将上面的xml称为anim_controller.xml
现在在你的线性布局中使用
android:layoutAnimation="@anim/anim_controller"
| 归档时间: |
|
| 查看次数: |
3417 次 |
| 最近记录: |