Image banner in android - android

if u check this steam page http://store.steampowered.com/
There is a banner which feature games, It move from right to left scroll horizontal transition which is automatic and can be scrolled left or right on press of button. I want to do same banner in android app. But right now i don't know how to start with. Need some ideas from you guys. I need efficient approach. Is it just one imageview and drawing and doing transition on its canvas. If yes then how does it work for my situation which is i am fetching images from web service via xml. SO this banner contents would be dynamic. The url of image will be in xml and i have to render those images in this banner with those transition as seen in steam page.
Thanks.

I'd suggest using a ViewFlipper and dynamically (in code) adding ImageViews. Keep in mind that loading multiple Images is very memory heavy.
You could load the shown picture +- 1 and adding/removing images on-the-fly when the shown image is switched. With this approach it would save memory and should be efficient.

Related

Android: Update ImageView Background while Behind other ImageView

I'm building an app where I want to swipe images as though they were photos on a stack. In other words, if I swipe the top image I want it to animate moving in the direction of the swipe and have the next image underneath it visible the whole time. To accomplish this, I'm using a FrameLayout and two ImageView containers. I'm just alternating which one is on top. Meanwhile, as soon as a swipe occurs, the next image is loaded into the ImageView at the back using setBackground(drawable). My problem is that the ImageView at the back doesn't update it's image until I call bringToFront() on it, which means that as the top ImageView is animating, the image underneath is incorrect until the animation completes, at which point it abruptly changes to the correct image. I've tried calling invalidate() on the rear ImageView after setBackground(drawable) but this doesn't work. Anyone have any ideas on how I can get the image to update while it's behind?
UPDATE: Turns out I'm just not very on it today. I was updating the wrong ImageView and because the image loading was being done off the network, there was just enough lag to make me think it was happening after the animation completed.
Sounds to me like you wanna do something like an Image Slider.
There are great libraries existing for this purpose, this one for example:
https://github.com/daimajia/AndroidImageSlider
If you don't wanna use this, here are some tips:
Images on ImageViews are set with setImageDrawable(Drawable)
When your animation starts, set the new Image to your ImageView behind and slide the visible one away.
When the visible ImageViewhas slided away, set it's visibility to GONEand move it behind the second ImageView
Do this for every time a new image is loaded.
This should actually work.
You need a "ViewPager"
https://developer.android.com/training/animation/screen-slide.html
It has all the necessary handles to accommodate "N" number of images - also supports multiple swipe animations - default handlers - efficient memory management - prefetching - you are all in for a feast with this !!
Just make sure you get the "ImageView" in the layout of the "pages" you wish to develop on the "ViewPager".

Android - Detect when imageview or layout appear no screen

I have an activity that gets data from a web service. The output of the web service consists of multiple sets of one web URL and some text. The URL points to an image. Each set is displayed by creating a linear layout which contains an imageview and textview. So, for 200 sets, I would have 200 layouts, 200 imageviews, and 200 textiews. I know that a list view would be a better solution, but I've gone too far in the project to change this now.
Currently, I download all images before the activity is displayed. I download around 200 images and in the future this might rise to more than 1000.
I would like to download the images only when the imageview appears on screen. The approach I am thinking of is creating some listener or event so that once the the imageview or layout appears on screen, the download starts. I searched a lot for this but could not find a good solution. My problem is creating the listener not starting the download.
Some solutions suggested lazy load but this would still mean all images are loaded which would not be appropriate for users who have limited download capacity.
Edit: I do not want to load all images, only the ones that appear on screen. And every time the user scrolls, the new imageview that appear on screen also start downloading.
I ended up using a different and easier approach by following #Akos's solution on this link for detecting the end of the scroll view. Once the activity starts, I load 10 layouts. Once the scroll view reaches the end, I display a progress dialog and load 10 more layouts.

How to do an infinite horizontal sliding scroll of images on Android using Delphi XE 5?

We want to show in an Android app a list of images in the similar manner with many gallery apps: horizontal sliding by using a gesture to show the next/previous image.
Also the image viewer should support zoom/pinch (besides other features).
Images can came from a database or from a directory and can be as much as 200-300.
The question is: Which is the best way to implement the slide-show part from the environment described above?
Through animations of a two TImage? There exist a specialized component for this? By using Horizontal Scroll box?
Stick 10 TRectangle objects in a THorzScrollBox. It could be more or less than 10 depending on the memory that the device has. Align them all to alTop. Load the images for display in TRectangle.Fill.Bitmap.Bitmap.
When the user scrolls down and is near the bottom of the ten, move the top rectangle to the bottom of the chain and load the newest image from your list into the new bottom one.
When the user scrolls up and is near the top of the ten, move the bottom rectangle to the top of the chain and load the newest image from your list into the new top one.
The reason behind doing it this way is that TRectangle is a really light image display container and you are recycling the TRectangle objects instead of deleting and creating them all the time.
It is possible that you will experience a display pop when you move the next TRectangle object to the top of the chain or when you move it to the bottom of the chain. You will have to create code to take care of this either by setting the position on THorzScrollBox or decreasing and increasing the height of the TRectangle as it leaves or enters the view until it is full size.
If you have installed samples with your Delphi instalation then you can find several examples of how to do this in:
Samples\FireMonkey\Fireflow
Samples\FireMonkey\MetropolisUIFlipViewDemo
Maybe there are even more of them. I haven't checked every sample so far.

Image auto scrolling in android

I want to create an image auto scrolling for an outer-space type of game. To make it more exact, I want to load 2 background image that uses a single image occupying the whole screen and auto-scroll it alternatively to create an animation that the background image is moving. Don't get confused with auto scrolling and and shifting to another image automatically. I really meant auto scrolling like moving background using 1 image.
I did some research but what I saw are segments of java codes that made me confused. If possible can anyone provide me an example? From loading the image from xml (should I use an imageview with this? or just set the background image of the layout?) and how I should process it in java code to make an image autoscrolling.
Any ideas guys? Thanks! Sorry for asking too much.

Android stacked image gallery

I'm trying to create a stacked image gallery, this is a gallery on which all the pictures are overlaying each other in a stack(or pile), for example: a card pile, and the user would be able to see and touch just the upper image and to flip/throw it out of the screen(with translate animation). After throwing the first picture the user will see the second picture that was hidden underneath the first one and so on.
I didn't find a similar gallery in other apps except to "weheartpics" (for Iphone off course)
The line of solution that I'm following now is to create a FrameLayout, adding some overlaying pictures on it, to delete the upper picture when the user touch it(instead of throw it out of screen).
Use StackView, available on API Level 11 and higher.
Why not use a ViewPager and flip through your images from left to right? You can then utilize FragmentStatePagerAdapter to prefetch and cache your images as use flips through these
All right - here's another way:
Add ViewSwitcher with 2 ImageViews
Since you can't use drag and drop library look for some alternatives but generally you want implement dragging the top image. Hopefully that will expose the hidden image but if not you will have to swap images when the drag starts
Implement gesture performed listener to listen for the flick events on the top image
When image is flicked away:
a. Swap image views in ViewSwitcher (if not swapped already for the drag-n-drop)
b. Pre-load next image into hidden ImageView
Otherwise return top image into original location (don't load anything into hidden ImageView)
Ok, the solution for that problem was to use frameLayout and to add to it imageView from the code. It's easy to apply animations on the images and to remove/add them after the animation begins.

Categories

Resources