小编Cra*_*aig的帖子

帮助框架动画Android

我一直试图让它使用这个线程,但似乎无法让它工作.

逐帧动画

我试图让屏幕在两个布局之间交替,我尝试了许多不同的东西,从状态列表drawables,形状drawables,甚至flipViews(flipViews不起作用,因为你不能改变背景,只是前景).

现在我得到一个空指针.如果你想指出我不能在动画中使用布局,那么请这样做,因为它可能是问题,但我不能确定.任何达到我最终目标的解决方案都表示赞赏.

我的Oncreate包含以下内容(减去标准内容)

ImageView mainimage = (ImageView) findViewById(R.id.main);
     mainimage.setBackgroundResource(R.anim.blink);
     AnimationDrawable blinkAnimation = (AnimationDrawable) mainimage.getBackground();
     blinkAnimation.start();
Run Code Online (Sandbox Code Playgroud)

我的动画文件包含:(减去utf的东西)

<

animation-list xmlns:android="http://schemas.android.com/apk/res/android"
        android:oneshot="false">
        <item android:drawable="@drawable/royalblue" android:duration="200" />
        <item android:drawable="@drawable/blank" android:duration="200" />
    </animation-list>
Run Code Online (Sandbox Code Playgroud)

Image视图中的Main只是这个空白的xml文件

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这是我放置在drawable文件夹中的布局,因为我希望它是动画中的一个框架.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/blinkBlue"
    android:background="@color/royalBlue"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"

    >

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这是我放在drawable文件夹中的另一个布局,因为我希望它是动画中的一个框架.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/blinkBlack"
        android:background="@color/black"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"

        >

    </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

animation android

2
推荐指数
1
解决办法
1513
查看次数

标签 统计

android ×1

animation ×1