J'ai commencé un projet et dans ce projet j'ai ajouté un RecyclerView à l'intérieur de NavigationView mais pour une raison quelconque, le RecylerView ne défile pas.
https://cdn1.imggmi.com/uploads/2019/7/31/d58464f32d8ebb24885b876f81ce2274-full.png
pré> XXX...
3 Réponses :
Remplacez
android:layout_height="wrap_content"
par
android:layout_height="match_parent"
dans votre Recyclerview.
@Jakob Je suis désolé. Je voulais dire Recyclerview au lieu de RelativeLayout. Essayez wrap_content dans votre Recyclerview.
Créez un vertical_recycler_view.xml
public class MyCustomViewGroup extends FrameLayout
{
public MyCustomViewGroup(Context context)
{
super(context);
RecyclerView verticalRecyclerView = (RecyclerView)
LayoutInflater.from(context).inflate(R.layout.vertical_recycler_view, null);
verticalRecyclerView.setLayoutManager(new LinearLayoutManager(context,
LinearLayoutManager.VERTICAL, false));
addView(verticalRecyclerView);
}
}
Vous devez gonfler et ajouter le RecyclerView où vous voulez:
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" android:scrollbars="vertical" android:layout_width="match_parent" android:layout_height="match_parent" />
J'espère que cela vous aidera!
Hell xavi jimenz. J'ai la vue du recycleur dans mon main_activity.xml et j'ai défini un adateur et un gestionnaire de mise en page sur mon MainActivity.java. Pouvez-vous me dire exactement où je dois utiliser ce code? Vouliez-vous dire une classe imbriquée dans MainActivity.
Créez de xml pour le recycleur. Créez une classe. Dans votre activité, vous devez créer une instance de cette classe et transmettre le contexte.
vous devez changer l'emplacement du contenu avec navigationView (navigationView doit être le dernier enfant)
<androidx.drawerlayout.widget.DrawerLayout 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:layout_gravity="end"
tools:openDrawer="end">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
// Content
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/digikala_navigation_drawer_header" android:id="@+id/navigationDrawerHeader"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/navigationDrawerRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/navigationDrawerHeader">
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
</com.google.android.material.navigation.NavigationView>
essayez d'utiliser wrap_content pour la hauteur de votre RecyclerView