Android: ViewFlipper & multiple images? - android

Hey, I checked tons of tutorials and guides but somehow can't find it...
I need to include multiple images in my Android app. It's like an image viewer/slideshow.
Currently I switch between pictures from /drawable-mdpi dir simply with ImageView and adapter, using gestures to left/right. Works but nothing impresive :/
Basically I could use something like Android (2.1) gallery with some image show animation.
1st question: what's the best way to include many (50-100) fullscreen images in App?
2nd: is it possible to use ViewFlipper animations directly to images? or do i have to somehow populate Views?

1st question: what's the best way to include many (50-100) fullscreen images in App?
Any approach that only involves a couple of images being in memory at one time. Full-screen images are large; you will run out of RAM.
2nd: is it possible to use ViewFlipper animations directly to images? or do i have to somehow populate Views?
You would have to use ImageViews as the children of the ViewFlipper.
I would recommend sticking with what you have and just apply animations.

Related

Displaying a stack of images

Given:
A number of images (10 - 15) residing in assets folder (as practice shows, the better approach is to keep high-resolution images in assets)
Android UI thread (caching drawables in advance is already made in a background thread)
The issue:
Need to display all the images one on another smoothly and not blocking UI thread after the images are drawn.
Already used approaches:
Dynamically create a required number of ImageView and then call .setImageDrawable(). This takes a lot of time but the worst thing is that the UI thread is being blocked even after all the images are drawn on their ImageView.
Create a LayerDrawable object and pass as argument an array of the required Drawables. Then put it on an ImageView also by calling .setImageDrawable(). This option behaves the same like the one described above.
Is there a way to solve this issue? Or Android devices not capable to cope with it?
Try Picasso library:
http://square.github.io/picasso/
It has support for resources:
Picasso.with(context).load(R.drawable.landing_screen).into(imageView1);
Picasso.with(context).load("file:///android_asset/DvpvklR.png").into(imageView2);
Picasso.with(context).load(new File(...)).into(imageView3);
If you are requiring a smooth transition between images, please try viewFlipper
https://developer.android.com/reference/android/widget/ViewFlipper.html
Basically you can add imageView inside the viewflipper and start animation to move from previous to next image. I am not sure if you need user interactions like scrolling or not. You can try viewPager if user need to scroll betweens images.
Please note that Glide does provide some transition effects for switching between placeholder and image to display. But transition between images are not included, you can have a look here
http://bumptech.github.io/glide/doc/transitions.html
I hope this helps because i am not sured that if you are asking the transition between images or rendering images.

How to set large number of items in ViewFlipper in Android

I have a ViewFlipper and an ImageView in it.I have large number of Images with me to load to the Imageview at run time.If the number of images is less its working fine.How can i achieve Image flipping with large number of images.Please help.
I ran into this same issue. If you are aiming at Honeycomb and newer advices use AdapterViewFlipper instead. You can pretty search/replace ViewFlipper for AdapterViewFlipper in your code (many methods are shared between the two), and then of course you need to pair it with an adapter extended from BaseAdapter. I did not find a lot of examples of doing so that were specific to AdapterViewFlipper, but the process is largely the same as for GridView, ListView, etc. This brief example helped get me going: http://www.mkyong.com/android/android-gridview-example/.

How to create custom Layout?

In my apps i want to display images and text in three ways
ListView
GridView
FullScreen
i have 500+ images and text that i parse using JSON and store into SQLite.
I know how to create ListView & GridView but problem is I don't know how to create the custom layout.
I have image but due to my low reputation i am not able to post image.
I try to explain what i need.
I need custom fullscreen layout that has 2 buttons, one on the left and other on the right and between those 2 buttons I need Imageview that display the fullscreen image.
thanks in advance
Use UniversalImageLoader library, as it has all the modes you need. It also supports caching and lazy load, which you will definitely need on 500 images.

appropriate container to display images one by one

I am new in android development. And I am building a location based app like google map(To some extent,we are reinventing the wheel :( ).
Like maps.google.com,the map data is generated as tiles in server and re-organized in the client. And in the html page,its easy to find the container to hold the tiles. For example,we can create some img element accordingly, and then put these imgs inside a div element.
Now in the android,which is the appropriate container to display the images?
In fact, I am reading the docs Displaying Bitmaps Efficiently, and it seems that ImageView is the only way to display the bitmaps. If this is true,then I have to create several ImageViewS dynamically according to the tile size and the size of the user screen. Also,according to the docs,AsyncTask should be used for performance enhancement. So each created ImageView will hold a AsyncTask,I am afraid which will out of my control.
So I wonder if there is any other solution can meet my requirement?
BTW,we use the tiles now,but we also have the plan to support the vector data which seems to have to use the opengl,so switch between different map types should be under consideration .
Update:
If as Raghunandan suggested I should use the ImageView to hold the satellite bitmaps in my app,but how about the vector data which should be still drawn use the opengl,then how to switch between these two types(views)?

Android gallery of drawables

I'm creating a simple Gallery of drawables - each of them is almost the size of a screen, so they require quite much memory. For each entry I'm creating a custom LinearLayout with ImageView and TextView for the title. As most of you know, android Gallery doesn't recycle views so it gallery will crash easily on low-memory phones (after loading 4 drawables on 16mb ram limit, in my case).
Here's the simple question - how do you implement such gallery, so it won't run out of the memory? How do you recycle these images? A working code example would be great.
Few notes:
inSampleSize isn't a way to go, I can't scale these images down
Calling recycle() on Drawable's loaded from resource is impossible, as it will crash on Android 4.0+ (it will recycle the drawable in their internal cache)
Don't ask me to post the code, as there is no.
You shouldn't be using Gallery because it's deprecated. Especially since there isn't any code written so far. The documentation suggests using a HorizontalScrollView or ViewPager.
I feel a ViewPager is what your looking for because it will only keep at most 3 pictures in memory and handels all the recycling for you. Here is a post with more information about how to implement one android viewPager implementation

Categories

Resources