Насколько я понимаю из того, что вы написали, вы хотите поместить Recyclerview на экран и разделить экран на 4. Добавьте 4 Recyclerview на экран, используя LinerarLayout
, и присвойте layout_weight
значениям 1 для каждого.
В этом;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#FF34FF" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#FFC107" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00BCD4" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#3F51B5" />
</LinearLayout>
Если вы хотите объяснить, что это не так, и вы хотите иметь 4 элемента в Recyclerview
и разделить экран на 4 равные части экрана Это не очень полезно для здоровья. Потому что Recyclerview
естественно содержит ScrollView
. Он будет скользить вверх и вниз по экрану автоматически. Если ваш экран будет состоять только из 4 элементов, то вы не можете использовать Recyclerview
и использовать LinearLayout
напрямую, добавить layout_weight
value
и назначить 1 каждому.
In that;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
tools:context=".MainActivity">
<RelativeLayout
android:id="@+id/recyclerView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#FF34FF">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="73dp"
android:text="Button" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="42dp"
android:layout_marginTop="89dp"
android:layout_toEndOf="@+id/button"
android:text="TextView" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/recyclerView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#FFC107" >
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="66dp"
android:text="Button" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="48dp"
android:layout_marginTop="79dp"
android:layout_toEndOf="@+id/button2"
android:text="TextView" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/recyclerView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#00BCD4" >
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="75dp"
android:text="Button" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="51dp"
android:layout_marginTop="87dp"
android:layout_toEndOf="@+id/button3"
android:text="TextView" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/recyclerView4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#3F51B5" >
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="36dp"
app:srcCompat="@drawable/ic_launcher_foreground" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginStart="54dp"
android:layout_marginTop="80dp"
android:layout_toEndOf="@+id/imageView"
android:text="TextView" />
</RelativeLayout>
</LinearLayout>
Вместо RelativeLayout
вы можете использовать желаемый макет.