0

I have a screen with two Edit texts and a button towards the bottom of the screen. Here is my xml:

        <EditText
                        android:id="@+id/editText1"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:maxLength="20"
                        app:layout_constraintTop_toTopOf="parent" />

        <EditText
                        android:id="@+id/editText2"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:maxLength="20"
                        app:layout_constraintTop_toBottomOf="+@id/editText1" />

        <Button
                    android:id="@+id/editBtn"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:enabled="false"
                    android:text="Edit"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@+id/editText2" />

This code is placed inside a constraint layout. The components should be connected to each other. But I want the button to be at the bottom of the screen without having to specify the margintop to avoid UI disruptions in different screen devices. Could you please let me know if this is possible.

Nikitha
  • 49
  • 5
  • `app:layout_constraintBottom_toBottomOf="parent"` to the button shouldn't work? – Zain Feb 03 '23 at 16:56
  • It works but I also want to constraint it to the component on top of the button i.e edittext. In that case the button will not be at the end of the screen. – Nikitha Feb 03 '23 at 17:39
  • Do you want the button stick to the EditText initially and when the EditText height got to the max, the button doesn't exceed the bottom of the parent? – Zain Feb 03 '23 at 18:36
  • you should use 2 constraint for your button: app:layout_constraintTop_toBottomOf="@+id/editText2" and app:layout_constraintBottom_toBottomOf="parent" they make button exactly between bottom of screen and bottom of edit text – Hossein Shahmohammadi Feb 03 '23 at 18:37
  • Yes exactly. I still want it at the bottom of the screen while having a constraint w.r.t the edittext. Because when the soft keyboard appears, the UI disrupts if the constraint is not set to the above UI component. – Nikitha Feb 03 '23 at 18:53
  • @Zain No I do not want it like that. I want to have a constraint that the button is at the bottom of the edittext also the button should be at the bottom of the screen – Nikitha Feb 03 '23 at 18:54
  • @Nikitha can you please attach image that you want to acheive – Tanishq Chawda Feb 04 '23 at 05:44
  • Have you tried using barriers and guidelines ? – Vivek Gupta Feb 04 '23 at 12:24

0 Answers0