views:

82

answers:

2

Hi

I am trying to do a layout similar to the one used in iphone for the weather app: http://www.spirituality.org.za/uploaded_images/MTN-South-Africa-iPhone-Weather-app-719447.jpg

This layout scrolls left/right very smoothly, and only loads the weather as you scroll.

HorizontalScrollView cant be used because it loads everything in memory, so not a good idea. Gallery will be similar to the iphone, but it has many problems when you put ListViews inside it, so also not good.

Is there any other layout like that? or do I have to build my custom layout? In case it must be custom, do you know any site/app/code where they have done something similar?

Thanks

A: 

You can use an ActivityGroup and then each "panel" could be a new activity that is launched with an intent that tells it what location to load the weather for. The layout within the panel looks like it's just a ListView with a header and footer. Or, if you only want a fixed number of days loaded you can just do a LinearLayout.

Window win = getLocalActivityManager().startActivity("MainActivity", new Intent(this, MainActivity.class));
mSwitcher.addView(win.getDecorView());
mSwitcher.setInAnimation(mSlideLeftIn);
mSwitcher.setOutAnimation(mSlideLeftOut);
mSwitcher.showNext();
CaseyB
thanks. I understand that with ActivityGroup I can have many activities into one. But how is the scroll part done?
Daniel Benedykt
I think that Apple has sample code for that in the references.
K-RAN
I am updating my answer to include some code.
CaseyB
Sorry, but if I understand correctly, this code just does an animation left/right. It doesnt follow the finger as the iphone for the weather app. thanks
Daniel Benedykt
That is true. This is the code I use to switch screens based on a button press. It was just meant to give you an idea of how to get it working, not be a ready made solution.
CaseyB
yes, got it, thank you very much for your help. I think the thing I want to do doesnt exist in Android. There are similar things like the gallery or horizontalScollView, but not the same effect.
Daniel Benedykt
A: 

The best way I found is to use a HorizontalScrollView, and overwrite the touch events so I can scroll one screen at a time, and draw as needed and not have all the views at the same time in the screen.

Daniel Benedykt