Android EasyBarrage實(shí)現(xiàn)輕量級(jí)彈幕效果
本文介紹了Android EasyBarrage實(shí)現(xiàn)輕量級(jí)彈幕效果,分享給大家,具體如下:
概述
EasyBarrage是Android平臺(tái)的一種輕量級(jí)彈幕效果目前支持以下設(shè)置:
- 自定義字體顏色,支持隨機(jī)顏色;
- 自定義字體大小,支持隨機(jī)字體大?。?/li>
- 支持邊框顯示,用于區(qū)分自己的彈幕和其他彈幕;
- 自定義邊框顏色;
- 彈幕數(shù)據(jù)是否允許重復(fù);
- 自定義單屏顯示的最大彈幕數(shù)量;
- 數(shù)據(jù)不重疊;
- 支持動(dòng)態(tài)添加彈幕;
- 不依賴(lài)VideoView,數(shù)據(jù)自動(dòng)循環(huán)顯示。
github:https://github.com/shiweibsw/EasyBarrage
顯示效果
橫屏
豎屏
使用
1 build.gradle
compile 'com.kd.easybarrage:library:0.0.1'
2 xml
<com.kd.easybarrage.BarrageView android:id="@+id/barrageView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/send" app:allow_repeat="true" app:border_color="@color/colorAccent" app:line_height="20dp" app:max_text_size="20" app:min_text_size="14" app:random_color="true" app:size="200"/>
屬性說(shuō)明
屬性 | 說(shuō)明 |
---|---|
max_text_size | 最大字體 |
min_text_size | 最小字體 |
size | 單屏最大彈幕數(shù)量 |
line_height | 行高 |
border_color | 邊框彈幕的邊框顏色 |
random_color | 是否啟用隨機(jī)顏色 |
allow_repeat | 彈幕內(nèi)容是否可重復(fù) |
3 Java代碼
添加彈幕數(shù)據(jù)
for (int i = 0; i < 200; i++) { mBarrages.add(new Barrage("彈幕數(shù)據(jù)" + i)); }
注意Barrage對(duì)象有多種構(gòu)造,可以設(shè)置字體顏色及是否顯示邊框,例如
3.1指定字體顏色
Barrage b=new Barrage("彈幕數(shù)據(jù)",R.color.colorAccent);
需要設(shè)置 app:random_color="false" 才有效
3.2顯示邊框
Barrage b=new Barrage("彈幕數(shù)據(jù)",true);
3.3指定顏色及顯示邊框
Barrage b=new Barrage("彈幕數(shù)據(jù)",R.color.colorAccent,true);
3.3只顯示內(nèi)容
Barrage b=new Barrage("彈幕數(shù)據(jù)");
添加一條彈幕
barrageView.addBarrage(new Barrage("我是新彈幕", true));
結(jié)束時(shí)調(diào)用destroy方法
barrageView.destroy();
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Android自定義View實(shí)現(xiàn)彈幕效果
- Android雙重SurfaceView實(shí)現(xiàn)彈幕效果
- Android實(shí)現(xiàn)視頻彈幕功能
- Android自制精彩彈幕效果
- Android編程實(shí)現(xiàn)簡(jiǎn)易彈幕效果示例【附demo源碼下載】
- 很棒的Android彈幕效果實(shí)例
- Android 實(shí)現(xiàn)仿網(wǎng)絡(luò)直播彈幕功能詳解及實(shí)例
- Android實(shí)現(xiàn)炫酷的網(wǎng)絡(luò)直播彈幕功能
- Android彈幕框架 黑暗火焰使基本使用方法
- Android仿斗魚(yú)直播的彈幕效果
- Android實(shí)現(xiàn)自定義的彈幕效果
- 實(shí)例解析如何在Android應(yīng)用中實(shí)現(xiàn)彈幕動(dòng)畫(huà)效果
- Android簡(jiǎn)單實(shí)現(xiàn)彈幕效果
相關(guān)文章
Android Recyclerview實(shí)現(xiàn)水平分頁(yè)GridView效果示例
本篇文章主要介紹了Android Recyclerview實(shí)現(xiàn)水平分頁(yè)GridView效果示例,具有一定的參考價(jià)值,有興趣的可以了解一下2017-08-08Android上傳多張圖片的實(shí)例代碼(RxJava異步分發(fā))
本篇文章主要介紹了Android上傳多張圖片的實(shí)例代碼(RxJava異步分發(fā)),具有一定的參考價(jià)值,有興趣的可以了解一下2017-08-08Android RecyclerView四級(jí)緩存源碼層詳細(xì)分析
RecyclerView是Android一個(gè)更強(qiáng)大的控件,其不僅可以實(shí)現(xiàn)和ListView同樣的效果,還有優(yōu)化了ListView中的各種不足。其可以實(shí)現(xiàn)數(shù)據(jù)縱向滾動(dòng),也可以實(shí)現(xiàn)橫向滾動(dòng)(ListView做不到橫向滾動(dòng))。接下來(lái)講解RecyclerView的用法2022-11-11Flexbox+ReclyclerView實(shí)現(xiàn)流式布局
這篇文章主要為大家詳細(xì)介紹了Flexbox+ReclyclerView實(shí)現(xiàn)流式布局,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-11-11Android Handler主線(xiàn)程和一般線(xiàn)程通信的應(yīng)用分析
本篇文章小編為大家介紹,Android Handler主線(xiàn)程和一般線(xiàn)程通信的應(yīng)用分析。需要的朋友參考下2013-04-04