У меня есть школьный проект, для которого мне нужно сделать приложение для Android.
Я использую Android Studio и Java для его программирования. У меня есть список, который отображает элементы из моей базы данных, но элементы в списке не там, где я хочу.
В настоящее время выглядит так .
Но я хочу, чтобы это выглядело так .
Я был бы очень признателен за помощь.
Я не знаю, где моя проблема, поэтому я включу весь связанный код. Прошу прощения, если мой английский плохой, я не являюсь носителем языка.
И это первый раз, когда я пишу программу на JAVA, поэтому, если вы видите ошибки новичка, пожалуйста, дайте мне знать также
Редактировать : мой новый и обновленный content_Main.xml
<?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"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main">
<android.support.v7.widget.CardView
android:layout_width="409dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/listview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TableRow
android:layout_width="match_parent"
android:layout_height="58dp">
<TextView
android:id="@+id/DatumVieuw"
android:layout_width="match_parent"
android:layout_height="57dp"
android:layout_marginBottom="108dp"
android:textAlignment="center"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:text="Halloo" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/watVieuw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
tools:layout_editor_absoluteY="40dp"
tools:text="Mijn" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/totTijd"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:textAlignment="textEnd"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/watVieuw"
tools:text="Is" />
<TextView
android:id="@+id/vanTijd"
android:layout_width="58dp"
android:layout_height="23dp"
android:layout_marginEnd="340dp"
app:layout_constraintEnd_toStartOf="@+id/totTijd"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/watVieuw"
tools:text="Naam" />
</android.support.constraint.ConstraintLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/TotDatum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:text="Ajaouin" />
<TextView
android:id="@+id/VanDatum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="viewStart"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="Nataro" />
</android.support.constraint.ConstraintLayout>
</TableRow>
</LinearLayout>
</android.support.v7.widget.CardView>
<Button
android:id="@+id/button"
android:layout_width="93dp"
android:layout_height="wrap_content"
android:layout_marginTop="532dp"
android:layout_marginEnd="144dp"
android:onClick="btnClick"
android:text="Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ListView
android:id="@+id/listview"
android:layout_width="wrap_content"
android:layout_height="324dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="216dp"
android:dividerHeight="10.0sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.375"
app:layout_constraintStart_toStartOf="parent" />
</android.support.constraint.ConstraintLayout>
Редактировать : Смещенные элементы:
<TextView
android:id="@+id/totTijd"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:textAlignment="textEnd"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/watVieuw"
tools:text="Is" />
<TextView
android:id="@+id/vanTijd"
android:layout_width="58dp"
android:layout_height="23dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/watVieuw"
tools:text="Naam" />
<TextView
android:id="@+id/VanDatum"
android:layout_width="wrap_content"
android:layout_height="25dp"
android:textAlignment="viewStart"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="Nataro" />
<TextView
android:id="@+id/watVieuw"
android:layout_width="412dp"
android:layout_height="47dp"
android:textAlignment="textStart"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
tools:layout_editor_absoluteY="40dp"
tools:text="Mijn" />
<TextView
android:id="@+id/DatumVieuw"
android:layout_width="419dp"
android:layout_height="40dp"
android:layout_marginBottom="108dp"
android:text="Halloo"
android:textAlignment="center"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:text="Halloo" />
<TextView
android:id="@+id/TotDatum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:text="Ajaouin" />
Редактировать : я исправил дерево компонентов, теперь оно вроде работает
фиксированное дерево компов
но теперь у меня новая проблема
новая проблема
* Редактировать: новый XML-код
<android.support.v7.widget.CardView
android:layout_width="409dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toTopOf="@+id/listview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TableRow
android:layout_width="match_parent"
android:layout_height="58dp">
<TextView
android:id="@+id/DatumVieuw"
android:layout_width="match_parent"
android:layout_height="57dp"
android:layout_marginBottom="108dp"
android:textAlignment="center"
android:textSize="30sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
tools:text="Halloo" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/watVieuw"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="24sp"
app:layout_constraintEnd_toEndOf="parent"
tools:layout_editor_absoluteY="40dp"
tools:text="Mijn" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/totTijd"
android:layout_width="wrap_content"
android:layout_height="22dp"
android:textAlignment="textEnd"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/watVieuw"
tools:text="Is" />
<TextView
android:id="@+id/vanTijd"
android:layout_width="58dp"
android:layout_height="23dp"
android:layout_marginEnd="340dp"
app:layout_constraintEnd_toStartOf="@+id/totTijd"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/watVieuw"
tools:text="Naam" />
</android.support.constraint.ConstraintLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/TotDatum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:text="Ajaouin" />
<TextView
android:id="@+id/VanDatum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="viewStart"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="Nataro" />
</android.support.constraint.ConstraintLayout>
</TableRow>
</LinearLayout>
</android.support.v7.widget.CardView>
Я добавил ограниченный макет самостоятельно, потому что мои элементы не будут сохранять свои позиции