1

Android newbie here. I know I can use TextView for scrolling text display but my question is a little different.

I want to show step by step details of moves in a game in a box on a View. It should be something similar to the scrolling text you see on most poker games. The requirements are you should be able to scroll through it to see the entire game moves. I am drawing the entire View using draw() and so was wondering how to get TextView on there. Can I add it to the View and position it myself in code? From what I see it seems like I should add TextView through the XML for the Activity. Is there another way around it or may be is there another widget I can use to solve my problem?

Thanks,

P

user220201
  • 4,514
  • 6
  • 49
  • 69

1 Answers1

1

You could try using a FrameLayout and overlay a TextView over your custom drawn view. It may be difficult to position the TextView precisely. Alternately you could extend ViewGroup and manage the view layout however you want.

slund
  • 6,367
  • 2
  • 26
  • 19
  • If I use a ViewGroup the TextView and the actual game layout are in two different Views which I would have to place properly and transfer information across views. I will have to give it a shot and see if the whole app feels as one screen or not but is there really no other way to add a widget to a screen in the same view? Is there an example somewhere to overlay a TextView over my view? Why did you say it might be difficult to precisely position it? – user220201 Apr 10 '11 at 18:09
  • Technically a ViewGroup is a View (if you look back in the class hierarchy, ViewGroup extends View). You can have the onDraw of a ViewGroup do your main painting, then use the onLayout method position the TextView where you want it. Even though two views are separate in a layout, they can still be accessed easily in the same Activity. The difficulty with a FrameLayout overlay is how to precisely position the TextView. I'm not a fan of using AbsoluteLayout (personal preference) – slund Apr 10 '11 at 20:47