I have 2 buttons and a TextView inside of a horizontal linear layout. All three views have weights. I have been unsuccessful in centering the two buttons vertically.
I have tried:
android:layout_gravity="center"
android:gravity="center"
Linear Layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#707070"
>
<Button
android:id="@+id/ratioLBButton"
android:text="LB"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:onClick="ratioLBFunction"
/>
<Button
android:id="@+id/ratioKGButton"
android:text="KG"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:onClick="ratioKGFunction"
/>
<TextView
android:text="Hello World"
android:textSize="18sp"
android:gravity="center"
android:id="@+id/ratioOutput"
android:background="#707070"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="5"
/>
</LinearLayout>
This is the parent Layouts that encompass the above views.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:background="#989898"
>
This is a screenshot from my tablet. It is the exact same on my android phone.