Я не понимаю, почему последний элемент из ListView
вроде "глючит". Почему я там отсутствует, это потому что ListView не выполняет родительский элемент внизу? Я так не думаю, потому что я установил minHeight в своем Item.
Я также пытался установить отступы внизу (как упоминалось в ответах из другого стека), но это не сработало.
Сначала давайте посмотрим на графический результат:
![enter image description here](https://i.stack.imgur.com/6hD3J.png)
Вот моя Активность :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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=".Activity.SelectSequenceStartPractise">
<fragment android:name="fr.izio.enhancedtabata.Fragment.MainHeader" android:id="@+id/main_header" app:layout_constraintTop_toTopOf="parent" android:layout_width="match_parent" android:layout_height="wrap_content" />
<com.google.android.material.textview.MaterialTextView
android:layout_marginTop="12sp"
app:layout_constraintTop_toBottomOf="@id/main_header"
android:id="@+id/select_a_sequence_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Select a sequence"
android:fontFamily="@font/exo2"
android:textColor="@color/design_default_color_primary"
android:textSize="32sp"
android:textAlignment="center"/>
<ListView
android:id="@+id/sequence_selection_container_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="22dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/select_a_sequence_text" />
</androidx.constraintlayout.widget.ConstraintLayout>
Вот мой Item (для адаптера):
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.CardView"
android:backgroundTint="@color/material_on_primary_emphasis_high_type"
android:minHeight="72dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="72dp"
android:padding="8dp">
<TextView
android:id="@+id/sequence_name_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fontFamily="@font/exo2"
android:text="My super sequence"
android:textColor="@color/design_default_color_primary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/sequence_time_duration"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fontFamily="@font/exo2"
android:textColor="@color/design_default_color_secondary"
android:text="Duration: 50 s"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<TextView
android:id="@+id/sequence_pause_time_duration"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="6dp"
android:fontFamily="@font/exo2"
android:textColor="@color/design_default_color_secondary"
android:text="Pause: 10 s"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
<TextView
android:id="@+id/sequence_contains_cycles_number"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fontFamily="@font/exo2"
android:textColor="@color/design_default_color_secondary"
android:text="Contains 5 cycles"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
И, наконец, вот метод getView из Adapter :
@NotNull
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
final Sequence sequence = super.getItem(position);
if (convertView == null) {
// Let's inflate the view
convertView = LayoutInflater.from(getContext()).inflate(R.layout.sequence_item_selection_start_practice, parent, false);
}
TextView sequenceName = convertView.findViewById(R.id.sequence_name_text);
TextView sequenceDuration = convertView.findViewById(R.id.sequence_time_duration);
TextView sequencePauseDuration = convertView.findViewById(R.id.sequence_pause_time_duration);
if (sequence != null) {
sequenceName.setText(sequence.name);
sequenceDuration.setText("Cycle duration: " + String.valueOf(sequence.sequenceDuration) + " s.");
sequencePauseDuration.setText("Pause duration: " + String.valueOf(sequence.sequencePauseDuration) + " s.");
}
return convertView;
}
Почему последний элемент ListView не соответствует ограничениям, которые я ввел в элемент?