Android中怎么利用EasyBarrage實(shí)現(xiàn)一個(gè)彈幕效果,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。
創(chuàng)新互聯(lián)公司-成都網(wǎng)站建設(shè)公司,專(zhuān)注成都做網(wǎng)站、網(wǎng)站建設(shè)、網(wǎng)站營(yíng)銷(xiāo)推廣,域名申請(qǐng),網(wǎng)站空間,網(wǎng)站托管運(yùn)營(yíng)有關(guān)企業(yè)網(wǎng)站制作方案、改版、費(fèi)用等問(wèn)題,請(qǐng)聯(lián)系創(chuàng)新互聯(lián)公司。概述
EasyBarrage是Android平臺(tái)的一種輕量級(jí)彈幕效果目前支持以下設(shè)置:
自定義字體顏色,支持隨機(jī)顏色;
自定義字體大小,支持隨機(jī)字體大小;
支持邊框顯示,用于區(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();
關(guān)于A(yíng)ndroid中怎么利用EasyBarrage實(shí)現(xiàn)一個(gè)彈幕效果問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
文章題目:Android中怎么利用EasyBarrage實(shí)現(xiàn)一個(gè)彈幕效果-創(chuàng)新互聯(lián)
文章起源:http://chinadenli.net/article10/ehego.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、用戶(hù)體驗(yàn)、品牌網(wǎng)站設(shè)計(jì)、品牌網(wǎng)站建設(shè)、標(biāo)簽優(yōu)化、網(wǎng)站維護(hù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容