почему мой горизонтальный просмотрщик не прокручивает фрагмент - PullRequest
0 голосов
/ 27 марта 2020

У меня есть два окна повторного просмотра в моем фрагменте: одно горизонтальное, а второе вертикальное, когда я прокручиваю горизонтальный рецилсер, но не прокручивает, а вертикальную прокрутку. в чем проблема ?

вот моя основная деятельность

<androidx.drawerlayout.widget.DrawerLayout

    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#242a38"
    android:fitsSystemWindows="true"
    tools:context=".ui.HomeActivity">


    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

      <FrameLayout
                android:id="@+id/fragment_container"
                android:layout_width="match_parent"
                android:layout_height="match_parent">


            </FrameLayout>


    </androidx.coordinatorlayout.widget.CoordinatorLayout>




    <com.ismaeldivita.chipnavigation.ChipNavigationBar
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="72dp"
        android:layout_gravity="bottom"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="0dp"
        android:background="@drawable/round"
        android:elevation="16dp"
        android:padding="8dp"
        app:cnb_menuResource="@menu/bottom_navigation_menu" />


    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#242a38"
        android:fitsSystemWindows="true"
        android:foregroundGravity="top"
        app:headerLayout="@layout/nav_header"
        app:itemIconTint="#FFFFFF"
        app:itemTextColor="#FFFFFF"
        app:menu="@menu/drawer_menu">


    </com.google.android.material.navigation.NavigationView>


</androidx.drawerlayout.widget.DrawerLayout>

мой домашний фрагмент

   <androidx.coordinatorlayout.widget.CoordinatorLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#242a38"
    tools:context=".ui.HomeFragment">



    <include layout="@layout/app_bar_home" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">



        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/myrecycler"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="11dp"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.0"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/textView10" />

        <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/posts_recycler"
                android:layout_width="match_parent"
                android:layout_height="250dp"
                android:layout_marginTop="20dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/myrecycler" />




    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

Ответы [ 2 ]

1 голос
/ 28 марта 2020

Вы должны использовать NestedScrollView и разместить там все ваши вертикальные и горизонтальные виды RecyclerView. Добавьте поведение nestedScrolling в ваши RecyclerViews.

0 голосов
/ 27 марта 2020

Вы можете указать макет вашего рейклера либо в XML, либо программно:

XML:

<android.support.v7.widget.RecyclerView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
 />

CODE :

LinearLayoutManager layoutManager
    = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);

RecyclerView myList = (RecyclerView) findViewById(R.id.my_recycler_view);
myList.setLayoutManager(layoutManager);
...