我将gif图片用作启动页面,但是当我尝试使用大屏幕(10.5英寸)进行模拟时,它不适合全屏显示。
我的启动页面布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cardview_light_background"
tools:context=".Splash">
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:src="@drawable/fneclis_splash_bg" />
</android.support.constraint.ConstraintLayout>
我的代码:
class Splash : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//hiding title bar of this activity
window.requestFeature(Window.FEATURE_NO_TITLE)
//making this activity full screen
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN)
setContentView(R.layout.activity_splash)
//2.63second splash time
Handler().postDelayed({
//start main activity
startActivity(Intent(this, MainActivity::class.java))
//finish this activity
finish()
},2630)
val gib = GifImageButton(this)
setContentView(gib)
gib.setImageResource(R.drawable.fneclis_splash_bg)
val mc = MediaController(this)
mc.setMediaPlayer(gib.drawable as GifDrawable)
mc.setAnchorView(gib)
gib.setOnClickListener(object : DialogInterface.OnClickListener, View.OnClickListener {
override fun onClick(p0: View?) {
mc.show()
}
override fun onClick(p0: DialogInterface?, p1: Int) {
mc.show()
}
})
}
}
还有其他方法可以将gif图像添加到android studio吗?
HEEEEEEEEEEEEEEEEEEEEEEEEEELP !!
答案 0 :(得分:0)
尝试将其添加到GifImageView:
android:scaleType="fitXY"