弹幕实现
- 添加依赖
implementation 'com.github.ctiao:DanmakuFlameMaster:0.9.25'
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
//添加在此处
implementation 'com.github.ctiao:DanmakuFlameMaster:0.9.25'
}
2.创建布局
效果图片
布局代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<master.flame.danmaku.ui.widget.DanmakuSurfaceView
android:layout_width="match_parent"
android:layout_height="300dp"
android:id="@+id/danmakuSurfaceView"
></master.flame.danmaku.ui.widget.DanmakuSurfaceView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:layout_width="wrap_content"
android