Android imageslider achieves cool rotation advertising effect

This example shares the specific code of Android imageslider to realize cool rotation advertising for your reference. The specific contents are as follows

This article is a serial of rookie nest author Liu Ting. " Let's talk about how to realize the imitation of "Jingdong Taobao shopping mall".

Android imageslider is a magical and convenient Android picture scrolling framework. In the rookie mall project, we will use this framework to realize cool rotation advertising.

Android imageslider architecture analysis

First, let's talk about the diagram. The following is the architecture analysis diagram of Android image slider.

The sliderlayout in the architecture analysis diagram is a custom view inherited from relativelayout, and it is also the core of the framework. It consists of sliderview and pagerindicator. The sliderview is divided into two parts: defaultsliderview and textsliderview. Defaultsliderview only supports picture loading and scrolling, while textsliderview supports not only picture but also text display. Transition effects and animation are mainly used to control animation effects. In addition, there are two important listening events: onsliderclicklistener and onpagechangelistener. As the name suggests, one is click event listening and the other is page switching event listening.

Basic use

Having understood the basic structure of the framework, the following is how to use it. The method used is also very simple.

1. Gradle dependency configuration

We use the Android studio 2.2.3 development tool here. For the specific method of eclipse referencing the third-party library, please refer to the Android imageslider source code description. Integrate the dependencies of third-party libraries in the build.gradle file.

2. Add permissions

To use the framework, you also need to add corresponding permissions, namely network permission and file reading permission.

3. Add to layout

Add sliderlayout to the corresponding layout file layout.

If you need a custom pagerindicator, you can customize it. Of course, you can also use the self-contained pagerindicator of the framework. Here is the source code of the custom pagerindicator.

4. Define and configure sliderlayout in activity / fragment

The first is to get the sliderlayout control and the custom indicator.

Then there is the data ready for testing. Here I define an entity class bannerinfo, including the picture imgurl and the description name. After defining the entity class, set the corresponding test data and add it to the scrolling picture list listbanner.

The next step is to configure the relevant properties of sliderlayout, add a custom indicator, set animation effects, add picture list data and set listening events

5. Stop sliderlayout scrolling in onstop()

Before the end of the activity / fragment life cycle, you need to stop the picture scrolling to prevent memory overflow and other problems.

Final effect

Run the code, and the effect diagram is as follows.

For more usage methods and functions of androidimageslider, please refer to the source code description of androidimageslider.

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