Tôi tạo một dự án nhỏ với RecyclerView với các mục CardView bên trong. Tôi đã tạo thẻ mở rộng (được mở rộng bằng cách nhấn vào nút nhỏ bên trong thẻ). Mỗi thẻ luôn chứa phần hiển thị (id: top_layout) và phần có thể mở rộng (id: expandable_part_layout).RecyclerView card mở rộngXem
Vấn đề là khi tôi mở rộng mục hoặc mục cuối cùng sau khi mở rộng có cạnh dưới bên dưới cạnh dưới của RecyclerView (một số phần của mục hoặc mục mở rộng là vô hình cho người dùng) RecyclerView sẽ cuộn lên tất cả các mục để hiển thị toàn bộ mục Tôi mở rộng. Tôi đã thử sử dụng scrollToPosition
và các phương pháp tương tự để cuộn đến cuối thẻ mở rộng nhưng không thành công.
Vì vậy, câu hỏi của tôi là làm thế nào để làm điều đó sau khi tôi mở rộng thẻ cuộn lên RecyclerXem chiều cao của phần mở rộng của thẻ? - Đó là ý tưởng của tôi, có lẽ ai đó có giải pháp tốt hơn.
<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>
Bạn có tìm thấy giải pháp cho vấn đề này không? Tôi có chính xác cùng một vấn đề. – Kerkhofsd
Tôi cũng quan tâm nếu bạn tìm thấy giải pháp cho việc này. – Allinone51
Rất tiếc, tôi chưa tìm thấy giải pháp. – Darko