Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use EasyBarrage to realize a barrage effect in Android

Shulou Source: shulou.com Published: 2022-05-31 22:03:24 09月21日 Update

Today, I would like to share with you how to use EasyBarrage to achieve a bullet screen effect in Android. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

Overview

EasyBarrage is a lightweight on-screen comment effect of Android platform. Currently, the following settings are supported:

Custom font color, support random color

Custom font size, support random font size

Support border display to distinguish between your own on-screen comment and other on-screen comments

Custom border color

Is the on-screen comment data allowed to be repeated?

Customize the maximum number of on-screen comments displayed on a single screen

Data do not overlap

Support for dynamic addition of on-screen comments

It does not depend on VideoView, and the data is displayed automatically.

Github: https://github.com/shiweibsw/EasyBarrage

Display effect

Horizontal screen

Vertical screen

Use

1 build.gradle

Compile 'com.kd.easybarrage:library:0.0.1'

2 xml

Attribute description

Property indicates max_text_size maximum font min_text_size minimum font size single screen maximum number of on-screen barrage line_height row height border_color border bullet screen color random_color whether random color allow_repeat on-screen comment content can be repeated

3 Java Cod

Add on-screen comment data

For (int I = 0; I < 200; iTunes +) {mBarrages.add (new Barrage ("on-screen comment data" + I));}

Note that the Barrage object has a variety of constructs, and you can set the font color and whether the border is displayed, such as

3.1 specify font color

Barrage b=new Barrage (on-screen comment data, R.color.colorAccent)

App:random_color= "false" needs to be set to be valid

3.2 display border

Barrage b=new Barrage (on-screen comment data, true)

3.3 specify color and display border

Barrage b=new Barrage ("on-screen comment data", R.color.colorAccentMagneTrue)

3.3 display content only

Barrage b=new Barrage (on-screen comment data)

Add a barrage

BarrageView.addBarrage (new Barrage ("I am the new bullet screen", true))

Call the destroy method at the end

BarrageView.destroy (); that's all of the article "how to use EasyBarrage to achieve a barrage effect in Android". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Tags: Data color font border support effect content knowledge article maximum size attribute quantity different large minimum valid code dynamic multiple Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MySQL macOS Shulou Technology Docker