Center two buttons horizontally

后端 未结 18 1306
我在风中等你
我在风中等你 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:17

    Attributes named android:layout_foo are LayoutParams - arguments to the View's parent. Try setting android:gravity="center" on the LinearLayout instead of android:layout_gravity. One affects how the LinearLayout will lay out its children within itself, the other affects how the LinearLayout's parent should treat it. You want the former.

提交回复
热议问题