Simple function example of electronic photo album using GridView and imageviewswitcher in Android

When viewing the photo album on the mobile phone, we first see the grid image display interface, and then we select the photo we want to enjoy and click to enter, so that we can watch the photo in full screen, and switch the photos by sliding left and right. As shown in the following figure:

Intent is required to realize the jump between activities and the transfer of photo tag positions, and putextra and getextra are used to pass in and obtain the tag positions of photos respectively.

(about intent, there will be a special blog post in the future to introduce the specific use, please pay continuous attention)

Let's start the implementation of the function:

Step 1: create a homepage GridView layout grid in layout_ Layout.xml file:

Step 2: create a griditem layout for each item in the GridView layout in layout_ Layout.xml file:

The settings here need to be scaled according to the width of the actual displayed picture and the resolution of the container (mobile phone) to be displayed, so as to avoid confusion in typesetting.

Step 3: create a picture display interface (including navigation dots) layout activity in layout_ Main.xml file:

Here, the main layout uses FrameLayout, the switching layout uses imageswitcher, and the navigation dot uses LinearLayout (which can be realized through the configuration file):

Step 4: the implementation code of activity in Java, and the implementation code of GridView on the homepage gridactivity.java:

The getview method in the custom adapter has been optimized:

Step 5: implementation code of activity in Java, implementation code of imageswicher after jump mainactivity.java:

This code presentation ends here. According to the above, you can try a variety of implementation methods. The intent used this time will be described in detail later. I hope you can support more 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
分享
二维码
< <上一篇
下一篇>>