I'm designing a Gallery View in Android where I need to have two views occupying each half of the screen (2 views on a full screen). When the user scrolls it shows the next view. The Ideas behind this is to have five views and user see 2 views initially. I tried a couple options but without success,where setLayoutParams(new Gallery.LayoutParams(screenWidth/2, screenHeight/2)); didn't really solve the problem. If anybody encountered this kind if an issue send me an advice or path. Thank you for reading and please let me know if you need any further details in case if I didn't make my self clear.
two views occupying each half of the screen (2 views on a full screen)
to acheive this give both the views equal weight so that both takes equal height(half - half screen). then in the
setLayoutParams(new Gallery.LayoutParams(screenWidth/2, screenHeight/2));
instead of setting the screenwidth/2 and height/2 use fill parent there...
Hope it helps...
if found any issues with this... post your layout and code relevant to that...
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.
As written in the topic, I have an android App, which has a design - that design is being shown differently on my Phone than in the XML-Preview.
Screenshots:
As you can see on my device, the button at the bottom is far more in the top than it should be. Any fixes?
This is because of the screen size. If you are just stacking the views in a LinearLayout they will take up whatever room they need and the the bottom will be blank. If you want you can make the button be pushed to the bottom by using layout_weight=1 on whichever view you want to take up the remaining space.
As I'm quite new to java I'm not sure if this is possible, so I ask you for help. I'm wondering if it is possible to have part of a viewpager hidden above the screen/under the action bar. I have attached an image for illustration.
What I want is for part of the viewpager to be above the actual screen, part of it shown and part of it under the rest of the layout. Reason behind this is that I want it to slide down and cover the whole screen when the user slides down (white layout slides down and out).
Is this possible? If so, could you give me any pointers to how. Thanks in advance.
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.
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.