【问题标题】:how to make a Gif image take the full screen (resizable)?如何使 Gif 图像占据全屏(可调整大小)?
【发布时间】:2019-01-22 17:40:30
【问题描述】:

我使用 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???

HEEEEEEEEEEEEEEEEEEEEEEEELP !!

【问题讨论】:

    标签: android image kotlin gif


    【解决方案1】:

    尝试将此添加到 GifImageView:

    android:scaleType="fitXY"
    

    【讨论】:

    • 同样的问题兄弟!!
    猜你喜欢
    • 2015-02-10
    • 2013-02-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-23
    • 1970-01-01
    • 2010-10-07
    相关资源
    最近更新 更多