Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #5150: Correct home screen topic grid misalignment after returnin…
…g from lesson (#5563) ## Explanation Fixes #5150 , where the home screen topic grid becomes misaligned after returning from a lesson. The grid alignment is now maintained upon returning to the home screen, ensuring a consistent layout for topics. ## Issue Description The home screen topics grid view experiences misalignment when navigating back from a lesson. This issue stems from inconsistent layout parameter management within the margin binding adapters, causing unexpected UI disruptions across different screen configurations. ## Changes Made - Refactored `MarginBindingAdapters` to prioritize `setLayoutParams()` over `requestLayout()` - Implemented a more robust approach to setting and preserving layout parameters - Ensured consistent margin application across various screen orientations and device types ## Reasoning The core of the fix lies in how layout parameters are managed: - `View.setLayoutParams()` explicitly sets layout parameters for a view - This method inherently calls `requestLayout()`, guaranteeing the view is redrawn with updated parameters - Direct parameter setting provides more predictable margin management across different screen configurations ## Test Coverage Comprehensive testing was added to `MarginBindingAdaptersTest` to validate: - Margin preservation across multiple screen configurations - Accurate application of start, end, top, and bottom margins - Consistency of layout parameter management - Robust handling of different device orientations (portrait, landscape, tablet) ## Essential Checklist - [x] The PR title and explanation each start with "Fix #5150: ". - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [x] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). --------- Co-authored-by: Adhiambo Peres <[email protected]>
- Loading branch information