在Module中的build.gradle文件里,添加以下依赖:
allprojects {
repositories {
jcenter()
mavenCentral() // 切记要添加这个
maven {
url 'https://dl.bintray.com/hpdx/maven/'
}
}
}
implementation 'com.anbetter:danmukulight:1.0.1'
XML:
<com.anbetter.danmuku.DanMuView
android:id="@+id/danmaku_container_broadcast"
android:layout_width="match_parent"
android:layout_height="80dp"/>
Java代码:
//启动(在这之前记得find id)
mDanMuContainerBroadcast.prepare();
DanMuModel danMuView = new DanMuModel();
//设置弹幕的方向
danMuView.setDisplayType(DanMuModel.RIGHT_TO_LEFT);
danMuView.setPriority(DanMuModel.NORMAL