I have 2 vertical linear layouts in one horizontal parent linear layout like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:textAllCaps="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:orientation="vertical"
<android.support.design.widget.AppBarLayout ...
<android.support.v7.widget.Toolbar... />
</android.support.design.widget.AppBarLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.1"
android:orientation="vertical"
android:id="@+id/imagebtn_layout">
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.9"
android:layout_marginRight="1dp"
android:orientation="vertical"
android:id="@+id/button_layout">
</LinearLayout>
</LinearLayout>
</LinearLayout>
Now I add 2 buttons programmatically to their views: One into imagebtn_layout and the other one into button_layout with the parameters: (LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT). The text of the button is set to 20.6f. The picture for the image button has 44x44 pixels.
The result looks fine on my Pixel 2 (1920x1080), but horrible e.g. on 2560x1440:
I'm not sure what's wrong. The result should be that the ImageButton and the normal button are on all screens at the same line.
Edit: Solved after using the solution from gmetax and setting android:layout_height in the parent view to "wrap_content" and adapting font size of text button.