Java 启动屏幕中的GIF不平滑
我在启动屏幕上实现了一个Gif(630kb,230 x 480) 它不是很平滑,在主活动开始前的一秒钟,它完全冻结 我正在使用Glide 4.10Java 启动屏幕中的GIF不平滑,java,android,splash-screen,gif,android-glide,Java,Android,Splash Screen,Gif,Android Glide,我在启动屏幕上实现了一个Gif(630kb,230 x 480) 它不是很平滑,在主活动开始前的一秒钟,它完全冻结 我正在使用Glide 4.10 implementation 'com.github.bumptech.glide:glide:4.10.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0' 我的喷溅屏幕 public class SplashScreen extends Activity {
implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
我的喷溅屏幕
public class SplashScreen extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.activity_splash);
ImageView imageView = (ImageView) findViewById(R.id.splashgif);
Glide.with(this)
.asGif()
.load(R.drawable.mygif)
.into(imageView);
Thread myThread = new Thread() {
@Override
public void run() {
try {
sleep(3000);
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
myThread.start();
}
}
下面是我的活动_splash.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/splash"
android:scaleType="centerCrop"/>
<ImageView
android:id="@+id/splashgif"
android:layout_width="wrap_content"
android:layout_height="300dp"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
我的应用程序包含许多小图像,这些图像需要一些时间才能加载,这可能是我的启动屏幕运行不顺畅的原因吗?
我能做些什么或者我必须接受它吗?最终图像视图ImageView=(ImageView)findViewById(R.id.splashgif)
你正在加载什么?你有没有看过它的大小,帧速率等等,我想这段代码和问题完全一样
runOnUIThread()
从另一个线程调用是有意义的,但从UI线程本身调用是有意义的??
runOnUiThread(new Runnable() {
@Override
public void run() {
Glide.with(getApplicationContext())
.asGif()
.load(R.drawable.mygif)
.into(imageView);
}
});
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
startActivity(intent);
finish();
}
}, 3000);