Is it possible to place one view over another in android?

后端 未结 5 1666
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-01 09:48

Can we place a small view over another large view? For example, I have a VideoView which is playing a file in the background. Over this, somewhere in the middle/corner, I wa

5条回答
  •  旧时难觅i
    2021-01-01 10:37

    The FrameLayout is the simplest ViewGroup and stacks the Views in the order they're defined in layout XML (or added programmatically); the first will be lower, and the last will be on top.

    Here is an example where two Views are stacked and offset to better illustrate the point:

    Here is the actual layout XML with the two overlapping TextView boxes. The offset of the two boxes is done using android:layout_gravity while android:gravity is used for centering the text itself within each box.

    
    
    
        
    
        
    
    
    

提交回复
热议问题