The list view item for my RecyclerView
are in a ConstraintLayout
. The ConstraintLayout
width is set to match_parent
. The list view item has two TextView
s and two buttons. The buttons have fixed widths but the TextView
s’ width are defined by layout_constraintHorizontal_weight
. They display as I intend in the Layout Editor but when I run the app the TextView
s are collapsed down to zero width. The Layout Inspector shows the ConstraintLayout
s’ layout_width
is set to wrap_content
, even though it was set to match_parent
at design time.
Recyclerview.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/lightestMoneyGreen"
android:paddingHorizontal="4dp"/>
</LinearLayout>
Summary_list_item.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:Tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animationCache="true"
android:background="@drawable/border_outline">
<TextView
android:id="@+id/committee_name"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="4dp"
android:layout_marginEnd="4dp"
android:gravity="center_vertical|start"
android:textColor="@color/black_text"
Tools:text="committee name"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/contribution_total"
app:layout_constraintHorizontal_weight="3.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/contribution_total"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:gravity="end"
android:textColor="@color/black_text"
Tools:text="total"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/rightArrowButton"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintStart_toEndOf="@+id/committee_name"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/rightArrowButton"
android:layout_width="24dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:adjustViewBounds="true"
android:background="#00000000"
android:contentDescription="@string/Expand_right_arrow"
app:layout_constraintBottom_toTopOf="@+id/expansionToggleButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_gold_right_solid_arrow_right_24" />
<ImageButton
android:id="@+id/expansionToggleButton"
android:layout_width="24dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:adjustViewBounds="true"
android:background="#00000000"
android:contentDescription="@string/Expand_up_down_toggle_arrow"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/rightArrowButton"
app:layout_constraintTop_toBottomOf="@+id/rightArrowButton"
app:srcCompat="@drawable/ic_gold_down_solid_arrow_lower_24" />
</androidx.constraintlayout.widget.ConstraintLayout>