最近项目有用到弹幕功能,一下就想到了B站开源的弹幕库,烈焰弹幕使
https://github.com/bilibili/DanmakuFlameMaster
看到github有很多issue都在提到的一些坑,这次来填一下我知道的坑
// 设置最大显示行数
HashMap maxLinesPair = new HashMap();
maxLinesPair.put(BaseDanmaku.TYPE_SCROLL_RL, 5); // 滚动弹幕最大显示5行
// 设置是否禁止重叠
HashMap overlappingEnablePair = new HashMap();
overlappingEnablePair.put(BaseDanmaku.TYPE_SCROLL_RL, true);
overlappingEnablePair.put(BaseDanmaku.TYPE_FIX_TOP, true);
mDanmakuView = (IDanmakuView) findViewById(R.id.sv_danmaku);
mContext = DanmakuContext.create();
mContext.setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 3).setDuplicateMergingEnabled(false).setScrollSpeedFactor(1.2f).setScaleTextSize(1.2f)
.setCacheStuffer(new SpannedCacheStuffer(), mCacheStufferAdapter) // 图文混排使用SpannedCacheStuffer
//.setCacheStuffer(new BackgroundCacheStuffer()) // 绘制背