Button always displays on top in FrameLayout

后端 未结 7 706
醉梦人生
醉梦人生 2020-12-03 00:34

I have FrameLayout like this:



        
7条回答
  •  长情又很酷
    2020-12-03 01:28

    As the official android documantation points out:

    FrameLayout is designed to block out an area on the screen to display a single item. Generally, FrameLayout should be used to hold a single child view, because it can be difficult to organize child views in a way that's scalable to different screen sizes without the children overlapping each other. You can, however, add multiple children to a FrameLayout and control their position within the FrameLayout by assigning gravity to each child, using the android:layout_gravity attribute.

    It's better if you put your Button and Textview in a RelativeLayout inside the FrameLayout like:

    
        
            
            

提交回复
热议问题