完整的使用方法請查看項目的Demo. java
1. 在build.gradle文件中加入依賴.dependencies { compile 'com.linsea:opendanmaku:1.0.0@aar' }
<com.opendanmaku.DanmakuView android:id="@+id/danmakuView" android:layout_width="fill_parent" android:layout_height="fill_parent" app:start_Y_offset="0.2" app:end_Y_offset="0.8" app:max_row="4" app:max_running_per_row="2" app:pick_interval="1000" app:show_debug="false" />
mDanmakuView = (DanmakuView) findViewById(R.id.danmakuView); // add danmaku items: mDanmakuView.addItem(list, true); mDanmakuView.addItem(new DanmakuItem(this, "Hello World", mDanmakuView.getWidth()); //show danmaku and play animation: mDanmakuView.show(); //hide and pause playing: mDanmakuView.hide(); //release all playing and waiting items: mDanmakuView.clear();
* start_Y_offset android
第一條播放航道距離彈幕View上邊緣的偏移量,注意值是百分比量,以彈幕View的高度爲基準,簡而言之就是彈幕View的上邊緣空出多少百分比. git
* end_Y_offset github
與上一個屬性相似,最後一條播放航道距離彈幕View上邊緣的偏移量,注意值是百分比量,以彈幕View的高度爲基準,主要做用是便於在彈幕View的底部留出必定的空白. app
* max_row ide
設置最多多少條播放航道. 佈局
* max_running_per_row gradle
每條航道上最多同時有多少條彈幕運行. ui
* pick_interval this
每隔多少毫秒取出一條彈幕來播放.
* show_debug
是否顯示航道線及播放幀率,調試時頗有用,主要用於調試.