Android native UI components are not re-layout on dynamically added views
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C++
- Star
- 127k
- Fork
- 25.3k
- Merge trung bình
- 1 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 4
Mô tả
Is this a bug report?
Yes.
Have you read the Contributing Guidelines?
Yes.
Environment
Environment:
OS: macOS High Sierra 10.13.2
Node: 8.9.4
Yarn: 1.3.2
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.4 => 0.55.4
Description
The issue can be noticed if you bridge to React Native the following views:
A view with elements that have a visibility to gone on the initial render won't be displayed after you've set is visibility to visible. view.isShown() will return true, but it will not be there or it will be there but not really re-layout.
A view with elements that are dynamically added, simply by view.addView() or let's say you want to load an image with Fresco it will only work if it was loaded on the initial render.
I've noticed that native components are re-layout on hot reloading, but this.forceUpdate() or changing props won't trigger a re-layout. As an ugly workaround, if we interact with the native component height or width it will trigger a re-layout, so every time you want to toggle a visibility from gone to visible or dynamically adds views you can alter his size.
I've also implemented needsCustomLayoutForChildren without notable change.
Expected Behavior (Native)
Here's the native implementation directly inflated inside an Activity.
Actual Behavior (React Native)
Here's the exact same layout as above, but bridged to react native and inflated inside SimpleViewManager.
Reproducible Demo
https://github.com/charpeni/react-native-android-visibility-issue
Related to #5531 (Already flagged in RN 0.18).
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với bản demo có thể tái hiện và component native được inflated thông qua SimpleViewManager. Tái hiện các trường hợp về khả năng hiển thị và view được thêm động, sau đó kiểm tra các cập nhật layout của React Native Android khác với phần triển khai Activity trực tiếp như thế nào, bao gồm cả lần thử needsCustomLayoutForChildren đã được báo cáo. Được xem là hoàn tất khi các view native được hiển thị hoặc thêm động được layout mà không thay đổi chiều rộng hoặc chiều cao, và hành vi của bản demo đã được xác minh.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- android, react-native
- Lĩnh vực
- mobile-dev
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100