Layout problem with button margin

后端 未结 3 1356
青春惊慌失措
青春惊慌失措 2020-11-30 10:04

I have problem with organizing layout in android aplication. I\'m dynamically creating buttons and adding them with this code to my layout:

    LayoutInflate         


        
3条回答
  •  青春惊慌失措
    2020-11-30 10:22

    Setting layout_weight on the buttons themselves will cause the buttons to expand without having space between them. LinearLayout never adds space between its child views.

    You should wrap each one in a FrameLayout and use layout_gravity="center" on your buttons, then set layout_weight="1" on the FrameLayout.

    
        

提交回复
热议问题