mainActivity.kt
val videoUri = Uri.parse("android.resource://" + packageName + "/" + R.raw.first );
binding.videoView.setVideoURI(videoUri);
binding.videoView.start();
binding.videoView.setOnCompletionListener {
binding.videoView.start();
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:context=".MainActivity">
<VideoView
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
ConstraintLayout -> RelativeLayout으로 변경.
VideoView를 삽입하고, 해당 내용을 작성한다.
=> VideoView Layout 아래부터 코드를 작성하면 동영상 레이아웃이 가장 하단에 쌓여,
z-index가 가장 낮은 순위가 된다.
포토샵으로 보자면, 동영상 레이아웃을 가장 아래에 놓고 위에 다른 레이아웃들을 쌓는 형태이다.
댓글 영역