我正在尝试显示带有公司徽标的动画视频,但对于尺寸应为多少感到困惑。当宽度完全适合时,高度会导致错误,而当高度完全适合时,宽度会导致错误。我正在将以下尺寸用于视频。
1280 * 1920
以下是XML代码
<androidx.constraintlayout.widget.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/white"
tools:context=".view.activites.Splashactivity"
>
<VideoView
android:id="@+id/splash_VideoView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
以下是用于显示视频的Kotlin代码。
try {
val path = "android.resource://" + packageName + "/" + R.raw.instored_splash_video
splash_VideoView.setVideoURI(Uri.parse(path))
splash_VideoView.start()
splash_VideoView.setOnCompletionListener {
jump() //change the screen
}
}
catch (e: Exception)
{
Log.d("SplashVideoExcept","$e")
jump() //change the screen
}
我需要在各种设备上显示视频,这有可能吗?