Center two buttons horizontally

后端 未结 18 1278
我在风中等你
我在风中等你 2020-12-12 13:32

I try to arrange two buttons (with images on them which work fine) next to each other and to center them horizontally. That\'s what I have so far:



        
18条回答
  •  庸人自扰
    2020-12-12 14:25

    Use a Relatie Layout instead of Linear and set gravity as android:gravity="center".

    Relative layouts give better performance and scale better if you run your application of devices of different sizes.

    Following as an example XML and resulting UI:

        
    
            
    
            
        
    

    enter image description here

提交回复
热议问题