1

Any ideas how we can make a menu like the one that Google has implemented in their YouTube app. I've read this, but that solution differs from the behaviour of the YouTube application. Does anyone know a real way to go about this?

I'm talking about this:

enter image description here

Community
  • 1
  • 1
Curtain
  • 1,972
  • 3
  • 30
  • 51

1 Answers1

1

I believe that they use a HorizontalScroll in a RelativeLayout.

Image that the menu is always there to the left. You make that first. Then you place a HorizontalScrollView on top of that and then put your main content in that. Set your horizontal scrolling properties to only scroll a certain max. Then you wire up your menu button to slide your horizontalscrollview to the max you set and that should be it.

You can always check the source to the People Application in ICS. They do something very similar.

Frank Sposaro
  • 8,511
  • 4
  • 43
  • 64
  • First, thanks for answering. Second, doesn't 'place a HSV on top' implies that the HSV will wrap around the menu, and hence, the menu will go along. Or am I wrong? – Curtain Jul 06 '12 at 13:38
  • No. Your using a RelativeLayout that has Z-indexing. So the menu will always stay in the same place and does not move. The HSV will still on top of that with your main content in it. This content covers up the menu. When the button is clicked the HSV just slides the content out the way to reveal your menu underneath. – Frank Sposaro Jul 06 '12 at 13:42
  • How does one add "z-indexing"? I haven't heard of that until now. And also, would it be possible to "swipe" this HSV? – Curtain Jul 06 '12 at 13:44
  • RelativeLayouts stack in linear order. So if you first put your menu view in your layout and then the HSV, it will stack them up for you with the view later in the layout being on top. Think of stacking cafeteria treys, that's Z-indexing. – Frank Sposaro Jul 06 '12 at 13:46
  • Okay, thanks. Do you think it also would be possible to add a "swiping" functionality instead of letting it scroll? – Curtain Jul 06 '12 at 13:49
  • yeah. Here is a good post on that http://stackoverflow.com/questions/5439790/android-swipe-leftright-gesture-detection – Frank Sposaro Jul 06 '12 at 13:50
  • I suppose you could even get rid of the HSV and just use a frameview and just adjust the left margin when the menu is touched or swyped. But not sure how that would effect the animation. – Frank Sposaro Jul 06 '12 at 13:52