Is there a similar method to "bringToFront ()" in linear layout?

Well I am making a game that uses a class that extends from SurfaceView

to represent the game screen, but it works with buttons, so I define the "button bar" in xml and then add "GameView" to the LinearLayout that contains all the stuff, programmatically and brings the "button bar" to the front, something like this:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    LinearLayout rl1 = (LinearLayout)findViewById(R.id.rl1);
    rl1.addView(new GameView(this));
    SquareLayout sq1 = (SquareLayout)findViewById(R.id.square);
    //the control buttons are in another custom layout called "SquareLayout"
    sq1.bringToFront();
}

      

The problem is that I want the layout to contain the game buttons (SquareLayout) to fill half the height of the RelativeLayout (the activity is set to landscape), I get this conversion of the RelativeLayout to a vertical LinearLayout by adding another SquareLayout and setting both weight properties to 1. and like this:

enter image description here

Now the problem is that "bringToFront ();" the method doesn't work on LinearLayout, so I can't change the z of the button bar after adding the playfield, so my question is if there is a way to make the button bar the same as in the image on the RelativeLayout or a similar method like "bringToFront ()" which works on LinearLayout.

+3


source to share


1 answer


Try calling a method bringChildToFront(View)

on your LinearLayout http://developer.android.com/reference/android/view/ViewGroup.html#bringChildToFront(android.view.View) . The parameter will be the view you want to display on top of your siblings.



0


source







All Articles