Reputation: 1
I am making a list with a recycler view and in each view item I want to put a card view, but it doesn't fit the full size, as shown in the image.
recylcerview code where it has the screen size recyclerview code:
<?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"
android:orientation="vertical">
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:layout_marginRight="30dp"
android:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="List"
android:textColor="@color/black"
android:textSize="24sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/buttonFE"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="1"
android:text="F - E" />
<Button
android:id="@+id/buttonPS"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="P - S" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewNumero"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView6"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="date"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView7"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="hour"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView9"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="repetitions"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView11"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="speed"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView10"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="state"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15sp"
android:textStyle="bold" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@color/black" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/Lista_registro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</LinearLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
cardview code: cardview code where it does not fit to the desired size
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView 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="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"
android:background="@color/white"
app:cardMaxElevation="1dp"
app:cardUseCompatPadding="true"
app:cardCornerRadius="2dp"
android:animateLayoutChanges="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:padding="5dp">
<TextView
android:id="@+id/textView_numero"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15sp" />
<TextView
android:id="@+id/textView_fecha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="date"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15sp" />
<TextView
android:id="@+id/textView_hora"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="hour"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15sp" />
<TextView
android:id="@+id/textView_rep"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="R"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15sp" />
<TextView
android:id="@+id/textView_vel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="S"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15sp" />
<TextView
android:id="@+id/textView_estado"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="1"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15sp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
How could I modify or change the code so that the list fits correctly in the recycler view, taking into account the screen size?
Upvotes: 0
Views: 15