Как поместить товар на полку с помощью Recycler-View

#android #xml #android-studio

#Android #xml #android-studio

Вопрос:

У меня есть картинка с набором полок. мы хотим поместить все три элемента на полку, как показано на рисунке.

изображение: это первое изображение

Я пытаюсь в этом коде

 <androidx.recyclerview.widget.RecyclerView
   android:id="@ id/rec"
 android:background="@drawable/boo"
   android:layout_gravity="center"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
 />
  

это результат

это мой код в MainActivity :

     GridLayoutManager layoutManager= new GridLayoutManager(this,3);
    recyclerView.setLayoutManager(layoutManager);
  

карточка товара recyclerview :

 <RelativeLayout
    android:id="@ id/relativeLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
    <TextView
        android:text="1"
        android:textSize="50sp"
        android:textStyle="bold"
        android:id="@ id/txt_number"
        android:gravity="center"
        android:padding="15dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />
    <TextView
        android:id="@ id/txt_title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_below="@id/txt_number"
        android:background="#00f"
        android:textColor="#fff"
        android:textSize="13sp"
        android:text="why are you here"
        android:gravity="center_horizontal"
        android:padding="20dp"
        />
</RelativeLayout>
  

Комментарии:

1. Поделитесь своим кодом.

2. я поделился своим кодом, чтобы увидеть его @FrancescoBocci