cuốn sách gpt4 ai đã làm

android - RecyclerView ngang bên trong ScrollView dọc

In lại Tác giả: Taklimakan Thời gian cập nhật: 2023-11-02 22:25:30 25 4
mua khóa gpt4 Nike

Vì vậy, tôi có RecyclerView nằm ngang bên trong ScrollView dọc. Mọi thứ trong bố cục của tôi hiển thị tốt và cuộn theo hướng tôi muốn và chạy trơn tru.

Vấn đề duy nhất tôi gặp phải là RecyclerView nằm bên dưới một số nội dung khác trong ScrollView và khi RecyclerView hiển thị một phần, nó sẽ căn chỉnh phần dưới cùng của RecyclerView với phần dưới cùng của màn hình khi khởi chạy. Điều này có nghĩa là nội dung phía trên RecyclerView sẽ bị đẩy ra khỏi màn hình.

Có ai biết tại sao điều này xảy ra và làm thế nào tôi có thể khắc phục nó?

Đây là một bố cục đơn giản thực hiện được những gì tôi vừa mô tả. Bạn thậm chí không cần phải điền vào RecyclerView, nó vẫn sẽ thực hiện việc đó.



xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">


android:orientation="dọc"
android:layout_width="match_parent"
android:layout_height="wrap_content">


android:layout_width="match_parent"
android:layout_height="500dp"
android:background="#fff"/>

<>
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#000"/>




câu trả lời hay nhất

Hóa ra vấn đề này đã được báo cáo cho Google tại đây Số phát hành-81854

Theo Google, nó hoạt động như mong đợi. Vấn đề là RecyclerView sẽ có thể lấy nétInTouchMode Đặt thành đúng. Để giải quyết vấn đề này tôi đặt có thể lấy nétInTouchModecó thể tập trung Đặt thành đúng.

Đây là bản sửa lỗi cho ví dụ mã tôi đã cung cấp trong câu hỏi ban đầu:



xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">


android:orientation="dọc"
android:layout_width="match_parent"
android:layout_height="wrap_content">


android:layout_width="match_parent"
android:layout_height="500dp"
android:background="#fff"
android:focusableInTouchMode="true"
android:focusable="true"/>

<>
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="#000"/>




Về android - Horizontal RecyclerView bên trong ScrollView dọc, chúng tôi đã tìm thấy một câu hỏi tương tự trên Stack Overflow: https://stackoverflow.com/questions/32394115/

25 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress