Android can dynamically add pictures, reflections and 3D effect examples to the gallery

This article gives an example of how Android can dynamically add pictures, reflections and 3D effects to the gallery. Share with you for your reference, as follows:

In Android, gallery can provide a good way to display pictures, achieve the above effect and dynamically add picture resources downloaded from the database or the network. We first implement a custom Gallery class.

MyGallery. java:

In layout file

In the above XML file, we used the custom mygallery.

Then an imageadapter class inherits from baseadapter.

In this class, the constructor needs to pass in the image data to be drawn in the gallery (take byte [] as an example, because I convert it into byte [] in the image demo stored in SQLite and downloaded from the network). Similarly, we use

In this article, it is explained in detail: https://www.oudahe.com/p/28335/

"Restore" the picture data of byte [] type. The image source data of byte [] type is saved in an ArrayList < byte [] >. In this way, we provide a data source for adding pictures to the gallery for dynamic implementation.

Use our customized baseadapter and gallery in the following activities. Achieve the effect shown in the figure above.

Using instance classes

Related to this article in this activity, that is, to add the picture function in the gallery, you only need to pay attention to some of the codes marked in the above code. As for the way of obtaining the data source, you only need to know that the data is an ArrayList < byte [] >. The important thing is to use the above mygallery and imageadapter. Of course, through simple understanding, these two classes can be easily reused in other projects

More readers interested in Android related content can view the special topics of this site: summary of Android graphics and image processing skills, introduction and advanced tutorial of Android development, summary of Android debugging skills and solutions to common problems, summary of Android multimedia operation skills (audio, video, recording, etc.), summary of Android basic component usage Summary of Android view skills, summary of Android layout skills and summary of Android control usage

I hope this article will help you in Android programming.

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