Viewpager introduction and simple implementation of guidance interface for Android UI design and development

It's almost more than a year to do Android development. I always want to write some of my experience in development, share with you and make common progress. I don't know how to start writing at the beginning. After thinking about it carefully, since I've just started writing, I'll start writing from the most intuitive feeling of a software - UI design, step by step. The blogger is here to study with you. I hope you can give more support. I don't say much. Let's start to explain the first article of UI design.

Before explaining how to achieve the effect of the boot interface, I want to introduce the use and description of the viewpager class in detail, because it is one of the most important classes for developing the boot interface.

1、 Effect diagram of viewpager implementation

2、 Functions implemented by viewpager

Seeing the above rendering, you must have guessed what this class is used for. The viewpager class provides a new effect of multi interface switching. The new effect has the following characteristics: < 1 > one of a group of interfaces is currently displayed< 2> When the user slides the interface left and right, the current screen displays part of the current interface and the next interface< 3> After sliding, the interface will automatically jump to the currently selected interface.

3、 Viewpager details

This is a software package compatible with low version Android devices officially provided by Google, which contains APIs that can only be used above Android 3.0. Viewpager is one of them. With it, we can do many things, from the simplest navigation to page menu and so on. How to use it? Similar to lisstview, we also need an adapter, which is pageradapter. Take a look at the API picture:

4、 Use of viewpager

Now that we know the functions and introduction of the viewpager class, how to use this class? Here we use it in three steps: 1. Add it to the living layout file.

2. Load the page card to display.

3. Instantiate the viewpager component in the activity and set its adapter (that is, pageradapter, the method is the same as listview). Here, it is generally necessary to rewrite the pageradapter.

This is a method to rewrite pageradapter. We can also do this:

As can be seen from the above picture, the adapter of viewpager is pageradapter, which is the base class. It provides an adapter to fill the interior of viewpager. You may want to use a more specific implementation, such as fragmentpageradapter or fragmentstatepageradapter. It needs to be explained here. In fact, viewpager should be used with fragment. At least Google officials think so, but under 3.0, we don't need to do so. Note that when you implement a pageradapter, you must override at least the following methods:

After explaining viewpager in this article, I believe you should also have a preliminary understanding of it. In the following articles, we will continue to focus on this class, hoping to help you have a deeper understanding of UI design and development.

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