android - linear layout bringToFront()

前端 未结 4 602
走了就别回头了
走了就别回头了 2021-01-12 04:23

I have 4 buttons in my linear layout and i need to bring to front first button.

Normal order is

    Button 1 | Button 2 | Button 3 | Button 4
         


        
4条回答
  •  终归单人心
    2021-01-12 05:17

    Since bringToFront messes up the LinearLayout order, I decided to use a RelativeLayout and put the "top" view (the view I want on top) last in the XML.

    Example:

    
    
        
    
        
        
    
    
    

    In the specific case of this question, the ViewOnTop would be the Button 1, and the ViewBelow would be a LinearLayout containing the other buttons.

提交回复
热议问题