Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/src/main/java/oyvindbs/zotshelf/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.graphics.Insets;
import androidx.viewpager2.widget.ViewPager2;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
Expand Down Expand Up @@ -47,6 +50,22 @@ protected void onCreate(Bundle savedInstanceState) {
viewPager = findViewById(R.id.viewPager);
fabAddTab = findViewById(R.id.fabAddTab);

// Handle window insets to prevent tab headers from overlapping with status bar
View rootView = findViewById(android.R.id.content);
ViewCompat.setOnApplyWindowInsetsListener(rootView, (v, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());

// Apply top inset to tab layout to prevent overlap with status bar
tabLayout.setPadding(
tabLayout.getPaddingLeft(),
insets.top,
tabLayout.getPaddingRight(),
tabLayout.getPaddingBottom()
);

return windowInsets;
});

// Setup tabs regardless of credentials (fragments will handle empty state)
setupTabs();
setupFab();
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">

<com.google.android.material.tabs.TabLayout
Expand Down