Reputation: 3850
I have an EditText
, which gets aligned with other TextView
below it.
But as soon as I add ListView
, and try to Left align with plain text at the top the width and location of the EditText
and TextView
fields below it changes.
Also, if I try to use another Linear Layout instead of a ListView
I face the same issue. What wrong could I be doing here?
I have tried setting width and height of listView, to match_contraint, but that did not work too.
Below is the xml for it,
<?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="com.example.testapp.app">
<EditText
android:id="@+id/editText6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="16dp"
android:ems="10"
android:inputType="textPersonName"
android:text="Name"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toStartOf="@+id/listView4"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="@+id/editText6"
app:layout_constraintStart_toStartOf="@+id/editText6"
app:layout_constraintTop_toBottomOf="@+id/editText6" />
<TextView
android:id="@+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="@+id/textView"
app:layout_constraintStart_toStartOf="@+id/editText6"
app:layout_constraintTop_toBottomOf="@+id/textView" />
<ListView
android:id="@+id/listView4"
android:layout_width="395dp"
android:layout_height="472dp"
app:layout_constraintHorizontal_weight="0"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="123dp" />
</android.support.constraint.ConstraintLayout>
Upvotes: 0
Views: 73
Reputation: 926
I think you put constraints in the wrong direction. So you aligned all TextView
s to the start of the EditText
. But EditText
in its turn is aligned to the start of the ListView
.
app:layout_constraintStart_toStartOf="@+id/listView4"
And as ListView doesn't have aligning, it is positioned at (0, 0), I guess.
Upvotes: 1