【问题标题】:How to play a transparent Video in Android?如何在 Android 中播放透明视频?
【发布时间】:2020-06-02 13:51:07
【问题描述】:

我有一个带有透明背景的视频,我想在我的 Android 项目中使用它。 我找到了this library,但它太旧了,性能也不是很好。 我怎样才能实现我的目标?

【问题讨论】:

    标签: android video transparent alpha


    【解决方案1】:

    你可以像这样使用videoview;

     <VideoView
                android:id="@+id/video_background"
                android:layout_width="0dp"
                android:layout_height="0dp"
                app:layout_constraintBottom_toTopOf="@+id/bottom_navigation_bar"
                app:layout_constraintEnd_toEndOf="parent"
                android:background="@color/transparent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />
    

    在你的活动中;

    videoBackgroundView = findViewById(R.id.video_background)
    val path = "android.resource://com.example.xxxxx" + "/" + R.raw.video
    videoBackgroundView?.setVideoPath(path)
    videoBackgroundView?.setOnPreparedListener { mp ->
        mp.isLooping = true
        videoBackgroundView?.start()
    }
    

    【讨论】:

    • 谢谢,但它对我不起作用。仍然是黑屏,因为它是背景
    • 只有在您正确阅读问题后才能发布答案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-10
    • 2020-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-10
    相关资源
    最近更新 更多