I've encountered some strange behaviour.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorAccent">
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Hi"/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Hi Hello"/>
</LinearLayout>
this code adds top margin to button that has two lines of text in it or something else that pushes it down.
The only workaround I've found to make it look as expected
is to add negative top margin and smaller padding to the button with two lines of text
<Button
android:layout_marginTop="-8dp"
android:padding="2dp"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="Hi Hello"/>
What causes that strange behaviour and how to handle it properly?