Я делаю небольшой проект с RecyclerView с элементами CardView внутри. Я создал расширяемую карту (расширенную, нажав на маленькую кнопку внутри карты). Каждая карта всегда содержит видимую часть (id: top_layout) и расширяемую часть (id: expandable_part_layout).RecyclerView расширяемый cardView
Проблема заключается в том, что при расширении последнего элемента или элемента, который после расширения имеет нижний край ниже нижнего края RecyclerView (часть элемента или расширенный элемент невидим для пользователя), RecyclerView должен прокручивать все элементы, чтобы показать весь элемент, который Я расширился. Я пробовал использовать scrollToPosition
и аналогичные методы для прокрутки до конца расширенной карты, но безуспешно.
Итак, мой вопрос заключается в том, как сделать это после того, как я расширю карту прокрутки вверх RecyclerView о высоте расширенной части карты? - Это моя идея, может быть, у кого-то есть лучшее решение.
<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>
Вы нашли решение этой проблемы? У меня точно такая же проблема. – Kerkhofsd
Мне тоже интересно, если вы нашли решение для этого. – Allinone51
К сожалению, я еще не нашел решение. – Darko