帮助与帧动画的Andr​​oid [英] Help with Frame Animation Android

查看:102
本文介绍了帮助与帧动画的Andr​​oid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图得到它使用这个线程工作,但似乎无法得到它的工作。

<一个href=\"http://stackoverflow.com/questions/3290290/please-help-me-with-frame-animaions-android-question\">Please帮我架Animaions! Android的问题。

我试图让两个布局之间的屏幕交替显示,并且我已经试过很多从状态列表可绘制不同的东西,塑造可绘制,甚至flipViews(flipViews没有工作,因为你不能改变的背景下,刚前景)。

现在我得到一个空指针。如果您想指出的是,我不能使用布局动画,那么请这样做,因为它可能是问题,但我不能肯定。
任何解决方案要达到我的最终目标是AP preciated。

我的OnCreate包含以下(减去标准的东西)

  ImageView的mainimage =(ImageView的)findViewById(R.id.main);
     mainimage.setBackgroundResource(R.anim.blink);
     AnimationDrawable blinkAnimation =(AnimationDrawable)mainimage.getBackground();
     blinkAnimation.start();

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

&LT;

 动画列表的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:单稳=假&GT;
        &LT;项目机器人:可绘制=@绘制/红深蓝机器人:时间=200/&GT;
        &LT;项目机器人:可绘制=@绘制/空白的机器人:时间=200/&GT;
    &LT; /动漫列表&gt;

主图形视图仅仅是这个空白的xml文件

 &LT; LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID /主
    机器人:方向=垂直
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    &GT;&LT; / LinearLayout中&GT;

这是我放在绘制文件夹中的布局,因为我想这是动画一帧。

 &LT; LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@ + ID / blinkBlue
    机器人:背景=@色/红深蓝
    机器人:方向=垂直
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT    &GT;&LT; / LinearLayout中&GT;

这是其他布局我都放在绘制文件夹,因为我希望它是在动画帧。

 &LT; LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
        机器人:ID =@ + ID / blinkBlack
        机器人:背景=@彩色/黑白
        机器人:方向=垂直
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT        &GT;    &LT; / LinearLayout中&GT;


解决方案

我知道,这是相当晚回应,但谁是这里面临着同样的问题,别人是我的解决方案:

  AnimationDrawable绘制=(AnimationDrawable)getResources()getDrawable(R.anim.amin_list)。
ImageView的IM =(ImageView的)findViewById(R.id.image);
IM .setBackgroundDrawable(绘制);
即时通讯。员额(绘制);

在哪里amin_list是:

 &LT;动画列表的android:单稳=假
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android&GT;
    &LT;项目机器人:可绘制=@绘制/ progress_1机器人:时间=150/&GT;
    &LT;项目机器人:可绘制=@绘制/ progress_2机器人:时间=150/&GT;
    &LT;项目机器人:可绘制=@绘制/ progress_3机器人:时间=150/&GT;
    &LT;项目机器人:可绘制=@绘制/ progress_4机器人:时间=150/&GT;
 &LT; /动漫列表&gt;

I have been trying to get it to work using this thread but can't seem to get it to work.

Please Help me with Frame Animaions! Android Question.

I am trying to get the screen to alternate between two layouts and I have tried lots of different things from state list drawables, to shape drawables, and even flipViews(flipViews didn't work because you cannot change the background, just the foreground).

Right now I am getting a null pointer. If you would like to point out that I can not use a layout in an animation then please do so as it's probably the problem but I can't be sure. Any solution to reach my end goal is appreciated.

My Oncreate contains the following(minus the standard stuff)

ImageView mainimage = (ImageView) findViewById(R.id.main);
     mainimage.setBackgroundResource(R.anim.blink);
     AnimationDrawable blinkAnimation = (AnimationDrawable) mainimage.getBackground();
     blinkAnimation.start();

My Animation file contains this:(minus the utf stuff)

<

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>

The Main in the Image view is just this blank xml file

<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>

This is the layout I have placed in the drawable folder because I want it to be a frame in the animation.

<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>

This is the other layout I have placed in the drawable folder because I want it to be a frame in the animation.

<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>

解决方案

I know that this is quite late response but for the others who are facing the same issue here is my solution:

AnimationDrawable drawable = (AnimationDrawable)getResources().getDrawable(R.anim.amin_list);
ImageView im = (ImageView) findViewById(R.id.image);
im .setBackgroundDrawable(drawable);
im .post(drawable);

Where amin_list is:

<animation-list  android:oneshot="false" 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/progress_1" android:duration="150" />
    <item android:drawable="@drawable/progress_2" android:duration="150" />
    <item android:drawable="@drawable/progress_3" android:duration="150" />
    <item android:drawable="@drawable/progress_4" android:duration="150" />
 </animation-list> 

这篇关于帮助与帧动画的Andr​​oid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆