Je fais un petit projet avec RecyclerView avec des éléments CardView à l'intérieur. J'ai créé une carte extensible (agrandie en appuyant sur un petit bouton à l'intérieur de la carte). Chaque carte contient toujours une partie visible (id: top_layout) et une partie extensible (id: expandable_part_layout). Problème: lorsque j'élargis le dernier élément ou élément qui après l'expansion a le bord inférieur sous le bord inférieur de RecyclerView (une partie de l'élément ou de l'élément développé est invisible pour l'utilisateur), RecyclerView doit faire défiler tous les éléments pour afficher l'élément entier J'ai élargi. J'ai essayé d'utiliser scrollToPosition
et des méthodes similaires pour faire défiler jusqu'à la fin de la carte étendue, mais sans succès.Carte extensible RecyclerViewVoir
Donc, ma question est de savoir comment faire que, après avoir développé la carte, faites défiler vers le haut RecyclerView à propos de la hauteur de la partie étendue de la carte? - C'est mon idée, peut-être que quelqu'un a une meilleure solution.
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="8px"
app:cardPreventCornerOverlap="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:id="@+id/top_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_alignParentTop="true"
>
<!-- some other controls -->
<ImageButton
android:id="@+id/card_header_inner_expand_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="?android:selectableItemBackground"
android:clickable="true"
android:padding="6dp"
android:src="@drawable/expand_icon" />
</RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/expandable_part_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/top_layout"
android:animateLayoutChanges="true"
android:clickable="false"
android:visibility="gone">
<RadioGroup
android:id="@+id/extened_stage_radiogroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:orientation="vertical">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RadioGroup>
<!-- some other controls -->
</RelativeLayout>
</RelativeLayout>
Avez-vous trouvé une solution à ce problème? J ai exactement le même problème. – Kerkhofsd
Je m'intéresse aussi si vous avez trouvé une solution pour cela. – Allinone51
Malheureusement, je n'ai pas encore trouvé de solution. – Darko