页面布局
首先是XML的layout布局,这里的总的父布局是一个FrameLayout用于贴上两个SurfaceView,一个用来播放视频,一个用来显示弹幕
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:orientation="vertical"
tools:context=".DanmuActivity">
<SurfaceView
android:id="@+id/sv_text"
android:layout_width="match_parent"
android:layout_height="400dp"/>
<SurfaceView
android:id="@+id/sv_media"
android:layout_width="match_parent"
android:layout_height="400dp"/>
/>
<EditText
android:id="@+id/et_text"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginTop="450dp"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="发送"
android:layout_marginTop="500dp"
android:onClick="Gogo"/>
</FrameLayout>
对象类
创建一个对象类来存放你所发送的弹幕
public class Danmu {
String text;<