1 | initial version |
You can use the android:layout_gravity
attribute and set it to center
for the button that you want to place over other buttons. Here is an example code snippet:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2"
android:layout_gravity="center"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 3"/>
</LinearLayout>
In the above code, the android:layout_gravity
attribute is set to center
for the second button, which will place it in the center of the linear layout and on top of the other buttons.