Android_Daily 2015-01-17 10:32 采纳率: 0%
浏览 1870

android 帧动画不显示大家帮我看看怎么个情况啊

 package com.example.animation;

import android.os.Bundle;
import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends Activity {
    AnimationDrawable an;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ImageView  iv = (ImageView) findViewById(R.id.imageView1);
        iv.setBackgroundResource(R.anim.my_animation);
        an = (AnimationDrawable) iv.getBackground();
        Button btn = (Button) findViewById(R.id.button1);
        btn.setOnClickListener(new  View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                // TODO 自动生成的方法存根
                an.start();
            }
        });

    }
}


<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" 
    android:oneshot="false">
    <Item android:drawable="@drawable/flash201" android:duration = "400"/>
    <Item android:drawable="@drawable/flash202" android:duration = "400"/>
    <Item android:drawable="@drawable/flash203" android:duration = "400"/>
    <Item android:drawable="@drawable/flash204" android:duration = "400"/>
    <Item android:drawable="@drawable/flash205" android:duration = "400"/>


</animation-list>




<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    tools:context=".MainActivity" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="100dp"
        android:layout_height="100dp"
         />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/imageView1"
        android:layout_marginLeft="43dp"
        android:layout_marginTop="50dp"
        android:text="Button" />

</RelativeLayout>


  • 写回答

1条回答 默认 最新

  • devmiao 2015-01-17 15:53
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料