Conversation
There was a problem hiding this comment.
Pull request overview
Adjusts the Bookmarks UI to remain well-aligned across device rotations by updating TabLayout behavior based on orientation, addressing the tab-title misalignment reported in #6700.
Changes:
- Apply an orientation-based
TabLayoutmode update during initial setup. - Handle runtime configuration changes in
BookmarkFragmentto re-apply the correctTabLayoutmode/gravity on rotation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| binding!!.tabLayout.visibility = View.GONE | ||
| } | ||
| } | ||
| override fun onConfigurationChanged(newConfig: android.content.res.Configuration) { |
There was a problem hiding this comment.
Why do we need to handle this manually? Could you check if we've set configChanges for the activity?
There was a problem hiding this comment.
config changes are set in the android manifest for Mainactivity which is host for bookmarkfragment
i think this pr is focused on manipulating the tablayout.mode and tablayout.gravity based on the current device orientation
There was a problem hiding this comment.
It's not recommended to forcefully prevent activity recreation. My understanding is that this is when we need to manually handle orientation changes. I would recommend checking for alternatives once for this.
There was a problem hiding this comment.
agreed which would mess with other parts of the activity
alternatives would be best with using styles
something like this .
<style name="BookmarkTabStyle">
<item name="app:tabMode">scrollable</item>
<item name="app:tabGravity">fill</item>
</style>
There was a problem hiding this comment.
@RitikaPahwa4444 You are right , Mainactivity file has configchanges set , this was a localized workaround without triggering a large refactor , If this approach is not satisfactory i can implement OnLayoutChangeListener on the Tablayout
There was a problem hiding this comment.
agreed which would mess with other parts of the activity alternatives would be best with using styles something like this .
<style name="BookmarkTabStyle"> <item name="app:tabMode">scrollable</item> <item name="app:tabGravity">fill</item> </style>
@rovertrack Thanks for the suggestion , However relying on XML styles won't actually work in this architectural scenario, since MainActivity uses configChanges="orientation|screenSize", the Fragment is never destroyed and the view hierarchy is never re inflated during rotation. This means Android won't dynamically swap between a values and values-land style the layout will just get permanently stuck in whichever style it was initially inflated with.
Also a quick heads up tabGravity is ignored by the framework whenever tabMode = "scrollable" is used
There was a problem hiding this comment.
No workarounds for config changes, please 🙂 I've pinned the issue where I've shared my thoughts, we've already patched a lot. So, any localised bug fixes might not get merged - there are some other long standing PRs too.
If, however, we're extending it to Main activity in general, we can discuss the approach.
Signed-off-by: Owm Dubey <owmdubey163@gmail.com>
ce40133 to
dd51942
Compare
|
✅ Generated APK variants! |
Description (required)
Fixes #6700
Handled configuration changes in BookmarkFragment to ensure proper UI behavior in landscape mode.
Tests performed (required)
Tested 6.3.0-debug on Pixel 9 Android 16
Screenshots (for UI changes only)
a.mp4