Skip to content

Commit 2935810

Browse files
Copilotgraycreate
andcommitted
Fix AppBar title bar overlapping status bar issue
Co-authored-by: graycreate <5203798+graycreate@users.noreply.github.com>
1 parent d3bfe7b commit 2935810

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

app/src/main/java/me/ghui/v2er/module/home/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public void onDrawerOpened(View drawerView) {
241241
@Override
242242
public void onStateChanged(AppBarLayout appBarLayout, AppBarStateChangeListener.State state) {
243243
isAppbarExpanted = state == State.EXPANDED;
244-
int paddingTop = isAppbarExpanted ? 0 : 36;
244+
int paddingTop = isAppbarExpanted ? 0 : Utils.getStatusBarHeight();
245245
mSlidingTabLayout.setPadding(0, paddingTop, 0, 0);
246246
}
247247
});

test_appbar_fix.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# AppBar Status Bar Overlap Fix Test
2+
3+
## Test Case: Verify AppBar Padding Uses Actual Status Bar Height
4+
5+
### Before Fix
6+
- Hardcoded `paddingTop = isAppbarExpanted ? 0 : 36;`
7+
- Fixed 36dp value doesn't account for different devices/Android versions
8+
- Issue occurs on newer devices like iQOO 13 with OriginOS 5 Android 15
9+
10+
### After Fix
11+
- Dynamic `paddingTop = isAppbarExpanted ? 0 : Utils.getStatusBarHeight();`
12+
- Uses actual status bar height from system resources
13+
- Should work correctly across all device types and Android versions
14+
15+
### Test Steps
16+
1. Launch the app on a device with different status bar height than 36dp
17+
2. Scroll down to collapse the AppBar
18+
3. Verify that the SlidingTabLayout has proper top padding
19+
4. Verify that the app title bar doesn't overlap with the system status bar
20+
21+
### Expected Results
22+
- The SlidingTabLayout should have padding equal to the actual status bar height when AppBar is collapsed
23+
- No visual overlap between app title bar and system status bar
24+
- Proper spacing maintained across different devices and Android versions
25+
26+
### Technical Verification
27+
- `Utils.getStatusBarHeight()` returns the correct status bar height in pixels
28+
- The method already handles fallback to 24dp for devices without proper resource identifiers
29+
- The fix maintains backward compatibility while solving the overlap issue

0 commit comments

Comments
 (0)