0

I'm doing a mini game just by using a linear layout with buttons and textfields. I want to have an overlay like the highscore overlay in flappy bird:

enter image description here

(the orange box in the middle)

Are there any ways to get this without converting my current layout into a canvas ? Thanks !

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Lara
  • 84
  • 1
  • 7
  • 30

1 Answers1

2

You need to change LinearLayout to a RelativeLayout. Make the overlay default as invisible, then use setVisibility(View.VISIBLE) on the overlay when you want it to show.

Sami Eltamawy
  • 9,874
  • 8
  • 48
  • 66
Gak2
  • 2,661
  • 1
  • 16
  • 28
  • And what does this overlay (the box) consists of then ? – Lara Mar 11 '14 at 18:18
  • you could make it another RelativeLayout, with all your imageviews and text and buttons inside it – Gak2 Mar 11 '14 at 18:20
  • where my overlay is supposed to be are other buttons and stuff right now, which I don't want to be moved aside when the overlay shows up – Lara Mar 11 '14 at 18:23
  • That's why you need RelativeLayout as your top ViewGroup. Positioning views in a RelativeLayout will just place them on top of the other views unless attributes like `android:layout_below` are set. – Gak2 Mar 11 '14 at 18:28
  • As my top ViewGroup ? I don't understand. My app was like this: http://i.imgur.com/FWyE4cN.png And I change it to this: http://i.imgur.com/l99EtGZ.png My testbutton is invisible though – Lara Mar 11 '14 at 18:46
  • Yes you're getting the idea. The testbutton is invisible because of the Z order. Put it below the LinearLayout and it should show up. Use `android:layout_centerInParent="true"` to center it. Then you can change the testbutton to a RelativeLayout or another LinearLayout and make an overlay. – Gak2 Mar 11 '14 at 18:53