There is such a layout Activity.

<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout 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" tools:context=".MainActivity"> <LinearLayout android:layout_width="0dp" android:layout_height="0dp" android:layout_marginStart="8dp" android:layout_marginTop="8dp" android:layout_marginEnd="8dp" android:layout_marginBottom="8dp" android:orientation="vertical" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="Button" /> <TextView android:id="@+id/textView" android:layout_width="310dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="dfgdfdfdfgnfgnfgngfnfgfgnfgnnfgnfgngfnfg" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:text="Button" /> </LinearLayout> </LinearLayout> </android.support.constraint.ConstraintLayout> 

Depending on the width of the screen, the size of the buttons is different, but you need to always be the same. Please tell me how to do this?

  • @GinTasan, there are two of them here, one is nested in ConstraintLayout , the other is in `LinearLayout`, that is, they are both nested. Could you concretize your comment? - Streletz pm

1 answer 1

Checked, you just need to remove the android:layout_weight="1" buttons

  • one
    By the way, setting a fixed width at the container also helps. But the option with android:layout_weight="1" IMHO is better. - Streletz pm