Question:
I have the following layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button>
<TableLayout>android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:layout_gravity="center_horizontal">
(Aqui tem algumas <TableRows>)
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:orientation="vertical">
<Button>
</LinearLayout>
</LinearLayout>
It is necessary to make it all vertically centered, from the first button to the last, keeping them organized as they are. I tried putting android:layout_centerVertical="true"
but it doesn't work. What should I do?
Answer:
Try using the android:gravity="center_vertical"
parameter in the parent LinearLayout. If you want to adjust each View separately, you can use the android:layout_gravity
parameter on the desired View.