Skip to content

Commit

Permalink
Fix API 35 display with appbar and systembar.
Browse files Browse the repository at this point in the history
  • Loading branch information
zorgluf committed Nov 27, 2024
1 parent 44e743e commit 3592656
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app/src/main/java/fr/nuage/souvenirs/AlbumListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.service.chooser.ChooserTarget;
import android.view.View;
import android.view.WindowInsets;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
Expand All @@ -28,7 +31,9 @@
import androidx.core.content.pm.ShortcutInfoCompat;
import androidx.core.content.pm.ShortcutManagerCompat;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.Insets;
import androidx.core.graphics.drawable.IconCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.fragment.NavHostFragment;
Expand Down Expand Up @@ -71,6 +76,17 @@ protected void onCreate(Bundle savedInstanceState) {
setSupportActionBar(toolbar);
NavigationUI.setupWithNavController(toolbar,navController);

findViewById(R.id.appbarlayout).setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@NonNull
@Override
public WindowInsets onApplyWindowInsets(@NonNull View view, @NonNull WindowInsets windowInsets) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
android.graphics.Insets systemBars = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
view.setPadding(0, systemBars.top, 0, 0);
}
return windowInsets;
}
});
}

private void updateShorcuts() {
Expand Down

0 comments on commit 3592656

Please sign in to comment.