-
Notifications
You must be signed in to change notification settings - Fork 46
fix: 修复在Pixel 10 Pro上ToolBar显示错误 #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- 为抽屉导航视图(NavigationView)添加状态栏内边距,以防止内容与状态栏重叠。 - 修正了在`AppBarLayout`滚动时工具栏(Toolbar)可见性的判断逻辑,确保其在向上滚动时能正确隐藏。
@claude help review |
Claude finished @graycreate's task —— View job PR Review: ToolBar Display Fix for Pixel 10 ProTodo List:
AnalysisRoot Cause Identified
This causes the toolbar to be hidden immediately when it should remain visible. Fix Analysis if (Math.abs(verticalOffset) >= toolbarHeight - statusBarHeight) { to: if (Math.abs(verticalOffset) > toolbarHeight) { Review Feedback✅ Positive Aspects:
Recommendations:
Overall Assessment: LGTM with Minor ConcernsThe fix correctly addresses the immediate issue and uses sound logic. While there are theoretical concerns about removing status bar awareness, the practical impact appears minimal since the toolbar positioning is handled by the AppBarLayout system. |
@Mystery00 感谢你的贡献!我测试了这个PR,发现了一个问题需要修正。 问题分析你的修改中添加了
因此 建议修改将条件从 // 只在实际滚动时隐藏toolbar(verticalOffset < 0)
if (verticalOffset < 0 && Math.abs(verticalOffset) >= toolbarHeight - statusBarHeight) {
mToolbar.setVisibility(View.INVISIBLE);
} else {
mToolbar.setVisibility(View.VISIBLE);
} 测试结果我在 Pixel 8 上测试了这个修改:
需要你确认由于我没有 Pixel 10 Pro 设备,请你在你的设备上验证这个修改是否也解决了原始问题。理论上这个修改应该可以同时解决两个问题:
请更新你的代码并测试,谢谢! 🤖 此评论由 Claude Code 生成 |
修改为 verticalOffset < 0 能解决原始问题,已经自测了 |
可能是因为Pixel 10 Pro上前置摄像头很高,所以设备的状态栏高度也很高,理论上不应该有什么兼容问题,但是在MainActivity中有一个自动隐藏的逻辑:
https://github.com/v2er-app/Android/blob/main/app/src/main/java/me/ghui/v2er/module/home/MainActivity.java#L244-L256
根据日志打印的情况,verticalOffset的值一直为0,但是toolbarHeight的值为125,statusBarHeight为151,判定走了隐藏ToolBar的逻辑,最终导致设备上不显示ToolBar,但是会显示ToolBar的区域,造成界面出现显示错误。
mNavigationView 组件也有相同的情况,但是那是因为没有设置Padding/MarginTop的原因。
相关截图:


相关打印代码: