Android homemade wonderful bullet screen effect

I haven't written an article for a long time. Recently, I found that the live broadcast is very popular. Many apps integrate the live broadcast function. I found that some live broadcasts have bullet screens with good results. Today, I wrote an article on making bullet screens on a whim

The results to be achieved today are as follows:

1. The barrage is fixed vertically

2. The vertical direction of the barrage is random

The white background in the above effect picture is the barrage itself, which is a custom FrameLayout. I set the position of the barrage to white for better display. Of course, if it is superimposed on the videoview, it needs to be set to transparent color. The following problems need to be considered in making the barrage: 1. The size of the barrage can be adjusted freely. 2. The items moving in the barrage (or subtitle) appears from the right side of the screen to the left side of the screen in the horizontal direction, and the vertical direction cannot exceed the height of the bullet screen itself. 3. After the subtitle is removed from the screen, the corresponding item (subtitle) needs to be removed from its parent container (bullet screen). 4. If the vertical height of the subtitle is random, it is also necessary to avoid subtitle overlap

OK, here is the code for the bullet screen custom view:

Barrage entity class:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>