AnimationDrawble 加载 GIF 动画的时候内存溢出
来源:互联网 发布:网络电话软件开发 编辑:程序博客网 时间:2024/06/05 06:02
Activity 代码
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ImageView rocketImage = (ImageView) findViewById(R.id.iv);
rocketImage.setBackgroundResource(R.drawable.my_animal);
new Thread(){public void run() {
SystemClock.sleep(20);
AnimationDrawable rocketAnimation = (AnimationDrawable) rocketImage
.getBackground();
rocketAnimation.start();
};}.start();
}
XML 代码
<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/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout>
Drawble 代码
<?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/a1"
android:duration="200" />
<item
android:drawable="@drawable/a2"
android:duration="200" />
<item
android:drawable="@drawable/a3"
android:duration="200" />
<item
android:drawable="@drawable/a4"
android:duration="200" />
<item
android:drawable="@drawable/a5"
android:duration="200" />
<item
android:drawable="@drawable/a6"
android:duration="200" />
<item
android:drawable="@drawable/a7"
android:duration="200" />
<item
android:drawable="@drawable/a8"
android:duration="200" />
<item
android:drawable="@drawable/a9"
android:duration="200" />
<item
android:drawable="@drawable/a10"
android:duration="200" />
<item
android:drawable="@drawable/a11"
android:duration="200" />
<item
android:drawable="@drawable/a12"
android:duration="200" />
</animation-list>
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final ImageView rocketImage = (ImageView) findViewById(R.id.iv);
rocketImage.setBackgroundResource(R.drawable.my_animal);
new Thread(){public void run() {
SystemClock.sleep(20);
AnimationDrawable rocketAnimation = (AnimationDrawable) rocketImage
.getBackground();
rocketAnimation.start();
};}.start();
}
XML 代码
<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/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</RelativeLayout>
Drawble 代码
<?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/a1"
android:duration="200" />
<item
android:drawable="@drawable/a2"
android:duration="200" />
<item
android:drawable="@drawable/a3"
android:duration="200" />
<item
android:drawable="@drawable/a4"
android:duration="200" />
<item
android:drawable="@drawable/a5"
android:duration="200" />
<item
android:drawable="@drawable/a6"
android:duration="200" />
<item
android:drawable="@drawable/a7"
android:duration="200" />
<item
android:drawable="@drawable/a8"
android:duration="200" />
<item
android:drawable="@drawable/a9"
android:duration="200" />
<item
android:drawable="@drawable/a10"
android:duration="200" />
<item
android:drawable="@drawable/a11"
android:duration="200" />
<item
android:drawable="@drawable/a12"
android:duration="200" />
</animation-list>
0 0
- AnimationDrawble 加载 GIF 动画的时候内存溢出
- 解决imageView加载图片时候造成内存溢出的问题
- 常见的gif动画加载
- Android的Gif动画加载
- gif文件的加载--实现动画效果
- Android加载Gif动画android-gif-drawable的使用
- Android加载Gif动画android-gif-drawable的使用
- WebView的loadUrl方法加载接口的时候,报堆栈内存溢出。
- Android 加载gif动画
- MFC加载GIF动画
- 加载中动画(gif)
- iOS 加载gif动画
- android加载GIF动画
- 加载Gif动画
- 优化加载gif动画
- Android加载GIF动画
- 切换VC的时候内存溢出崩溃
- bitmap时候内存溢出
- ASP+xml 如何来更新ASP.net缓存,菜鸟请叫更为大神
- 打开一个文件的时候会弹出一个打开方式 问:给系统这个打开方式加一个位移动画
- Android Studio ubuntu中如何旋转自带的原装模拟器,我需要横屏
- Android NFC标签写入问题
- 新人求教,如何在IOS系统上开发出VPN的客户端?
- AnimationDrawble 加载 GIF 动画的时候内存溢出
- 现在的AR SDK都是支持AndroidStudio。那Eclipse项目怎么办呢?
- 静态引用非静态出错
- 2017
- cocos2dx游戏开发
- 由于bad_param无法分享到微信
- 如何让百度地图显示出来?(问题出现位置已用!!!表示)
- [SPOJ TBATTLE Thor vs Frost Giants]单调队列+质因子分解
- UIAlertController 中的message中的内容如何设置文本居左显示