android实现弹幕效果(第三方)

本文介绍了如何在Android应用中实现弹幕效果,通过添加依赖、创建布局以及编写相关代码,展示了弹幕功能的实现步骤,并提供了效果图片和完整的代码示例。
摘要由CSDN通过智能技术生成

弹幕实现

  1. 添加依赖
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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值