Ad bar scrolling effect of Android custom control

On some e-commerce websites, you can often see some rolling advertising strips. Many software also have similar advertising strips when they are used for the first time, as shown in the figure:

In fact, there are controls to achieve this effect on GitHub, but it is also very simple to do. Let's see how to do it today.

Let's look at the layout file first:

The top of the layout file is a viewpager, which is used to realize the picture scrolling effect. The bottom of the viewpager is a LinearLayout. There are two things in the layout file, one is textview, which is used to display the lower line of words, and the other is a LinearLayout, which is used to display the small dots under the words, The number of small dots should be added dynamically according to the number of pictures, so leave it empty now.

MainActivity.java

The comments in the code have been very detailed, so I won't repeat them.

Unselected dot pointer_ disable.xml:

Small dot pointer when selected_ focus.xml:

Selector for small dots:

Source code download: http://xiazai.jb51.net/201606/yuanma/Androidmove (jb51.net).rar

Original link: http://blog.csdn.net/u012702547/article/details/45845613

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
分享
二维码
< <上一篇
下一篇>>