I've been learning android programming for some days. I am creating an ebook application which reads images from the drawable folder. I've successfully implemented the pageviewer activity which loads bitmaps using asyncTask in background and shows a text "loading..." until loading is completed.
I wanted to show a pagelist in another activity using gridview so that user can scroll through a grid of pages and select any. I followed the android gridview tutorial and wasnt much problem. But since i have about 50 images in drawable and it seems gridview adapter shows the grid once all images are croped and placed in grid. It takes a lot of time to show the grid and its quite slow on scroll.
I was wondering if there was a better way to show the grid, asynchronously, like show the first item and then the 2nd and so on, instead of waiting for a long time and displaying the grid. I saw some topics like lazy load which seems similar to what i want, but they all show image from web, it was confusing. Hope i can get some sugestions, or if there is any other way.
Have you tried Fedor's Image Lazy Loader?
Here is the link: Lazy load of images in ListView ,
I know you want to implement it for GridView, but still you can refer the ImageLoader class given in the example code.
Update:
You can even try this example Lazy Loading GridView. I haven't tried it, but as i found it, i thought it may be of your help.
The images you show are probably a bit too large to be used with GridView in their current form.
I guess you need the GridView to display thumbnails, so one possible approach would be to store a thumbnail sized copy of every page you have, and use those in the Grid.
You can also try switching hardware acceleration on in the manifest, that might help you with the scrolling once the images are small enough to load them faster. But afaik hw acceleration is only available in 3.0 and up.
Related
I'm relatively new to coding, especially with android(xml,java).
I had an idea for an app but it appears that it requires a layout that I can't seem to find.
So what I'd need is a layout that starts out with the screen size and dynamically expands in the given direction as the user drags along the screen.
In addition to that I want to be able to create objects(textview, imageview) at any given point on the layout which can also overlap as they can in Absolute- or RelativeLayout. Those objects should dynamically be loaded and destroyed as they move in and out of view.
So I don't know if there's anything like this. I've searched for quite a bit but only found layouts that were able to either scroll horizontally or vertically.
If anybody got an idea how I could possibly realize such a view, please let me know!
Best regards, BlackCert
In your case, doing everything manually through OpenGL seems appropriate. You could render only the items that are visible and dont have to mess with Android getting painfully slow when dealing with huge layouts. Set-Up a 2D scene and write rendering code for each kind of item you want to display.
I want to have an ImageView that slowly zooms/scales/pans the image inside of it. I want it to fill the parent container, in my case, the entire phone view, so that it shows no blank spaces around the image.
An example of what I want is how Facebook home works. It slowly either zooms into the image, and back out, or it pans the image across the view slowly. I've looked online at zooming images with gestures, but I can't seem to translate it well so it automatically does it.
Does anyone have any classes or libraries that can mimic the effect that Facebook Home does?
Old question, I know, but in case anyone else stumbles upon this...
I've used KenBurnsView from https://github.com/flavioarfaria/KenBurnsView
Works pretty well for what you're describing!
I want to do following things:
1-Create a grid(Size is depend on number of image series) of images on one screen
2-When clicked/chosen a image.
3-second grid (Size is depend on number of image series) of images will be on screen.
4-Horizontal Swipe the first screen to next one to display the other grid(i.e remaining images)
5-When clicked/chosen a image on last grid, an image or layout will be on screen.
Similar to the Grid we see in our android Phone's
Any answer truly Appreciated...
Assuming I understand this correctly, you are probably thinking of a GridView, which takes an adapter to populate the grid with images, just like an adapter for a ListView populates the list with Textviews (or whatever you have in your custom adapter layout).
As for the support to select an image to go to another grid (subdirectories of images?) and swiping between various grids, this would be done using Fragments. For the subdirectory stuff, I don't know if there is an API somewhere to help with this, but if not you would need to implement a recursive tree structure: the internal nodes would define a point that can be selected to navigate to the next level, and the external nodes would be the individual images. Selecting an internal node would enter that subdirectory, and selecting an external node would open a second Fragment with the larger view of the image.
This is all a bit vague, but hopefully it gives you a place to start looking around. Read the developer docs on GridViews and Fragments to see if they help at all.
Here's the situation:
I have a custom list item containing an ImageView, and some TextViews. I am lazy loading images to the ImageViews. When I use this in a ListView, it works fine.
I also want to use it in a Gallery. There are three scenarios:
lazy load images, not touching the spacing: The items overlap, but
scroll fine
don't load images, Gallery.setSpacing(0): The items are spaced
correctly, the scrolling works, but I have no images.
lazy load images, Gallery.setSpacing(0): The items are spaced
correctly, scrolling doesn't work, just behaves really jittery and
snaps back to original position. If I scroll very fast, repeatedly, it will start moving, but very poorly
Because it all works perfectly in a ListView, I can't understand what's going wrong. I know it's nothing wrong with my image loader, and I know it's nothing wrong with my layout. It seems like Gallery is having trouble handling changes to the list item.
EDIT: I forgot to mention, there's a placeholder image loaded in the ImageView before the images are loaded, and the ImageView has a fixed size.
Does anybody have any idea what I could be missing?
I think that because yo are lazy loading the images, when onMeasure is called on each item in the gallery, it doesn't know how big the image going to be (as it isn't loaded yet), and so it can't set the spacing to 0.
Maybe you should set your default gallery item size, or update the size of the view as the image is loaded?
I'm trying to create a "scrollable" layout in Android. Even using developers.android.com, though, I feel a little bit lost at the moment. I'm somewhat new to Java, but not so much that I feel I should be having these issues--being new to Android is the bigger problem right now.
The layout I'm trying to create should scroll in a sort of a "grid". I THINK what I'm looking for is the Gallery view, but I'm really lost as to how to implement it at the moment. I want it to "snap" to center the frame, like in the actual Gallery application.
Essentially, if I had a photo gallery of 9 pictures, the idea is to scroll between them up/down AND side to side, in a 3x3 manner. Doesn't need to dynamically adjust, or anything like that, I just want a grid I can scroll through.
I'm also not asking for anyone to give me explicit code for it--I'm trying to learn, more than anything. But pointing me in the right direction for helpful layout programming resources would be greatly appreciated, and confirming if it's a Gallery view I'm looking for would also be really helpful.
EDIT: To clarify, the goal is to have ONE item on screen at a time. If you scroll between one item and the next, the previous one leaves the screen, and the new one snaps into place. So if it were a photo gallery, each spot on the grid would take up the entire screen size, approximately, and would be flung out of the viewable area when you slide across to the next photo, in either direction. (Photos are just an example for illustration purposes)
This page gives a good summary of the different built in layout objects. From your description a GridView or possibly a TableLayout might work. GalleryView looks to be horizontal only.
I believe GridView is what you're looking for. Here's a tutorial: http://developer.android.com/resources/tutorials/views/hello-gridview.html
You should check out the ViewPager widget, which is available in the Android compatibility package. I spent a loooong time trying to get the Gallery widget to behave properly, but finally settled on a ViewPager which returned ImageView objects instead. Works like a charm.