Demo
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center"
android:padding="16dp">
<TextView
android:id="@+id/text_view_01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VideoView Demo"
android:textSize="32dp"
android:layout_centerHorizontal="true"/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text_view_01">
<VideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</FrameLayout>
</RelativeLayout>
MainActivity.java
package com.example.recyclerview;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.MediaController;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
import android.widget.VideoView;
import static com.example.recyclerview.Data.IMAGE_DRAWABLES;
import static com.example.recyclerview.Data.PROFILE_TEXT;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView videoView = findViewById(R.id.video_view);
videoView.setVideoPath("android.resource://"+getPackageName()+"/"+R.raw.video_sample);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
videoView.setMediaController(mediaController);
}
}
'System Programming > Android' 카테고리의 다른 글
[Android/Java] bitmap 예제(00) (0) | 2021.06.13 |
---|---|
[Android/Java] Media player(local storage) (0) | 2021.06.13 |
[Android/Java] 체크박스 (0) | 2021.06.13 |
[Android/Java] radio button (0) | 2021.06.13 |
[Android/Java] drawer menu (0) | 2021.06.12 |