Код: Выделить всё
AppBarLayout[*]
Код: Выделить всё
DrawerLayout[*]
Код: Выделить всё
NavigationViewво время активности oncreate , я вызываю эту функцию.
Код: Выделить всё
private void edgeToEdgeIfPossible(boolean windowLightStatusBar) {
if (windowLightStatusBar) {
EdgeToEdge.enable(
this,
SystemBarStyle.light(
ContextCompat.getColor(this, android.R.color.transparent),
ContextCompat.getColor(this, android.R.color.transparent)
)
);
} else {
EdgeToEdge.enable(
this,
SystemBarStyle.dark(
ContextCompat.getColor(this, android.R.color.transparent)
)
);
}
}
Код: Выделить всё
private void edgeToEdgeIfPossible() {
final RecyclerView recyclerView = getListView();
if (recyclerView != null) {
// 1. Allow content to be drawn behind the navigation bar
recyclerView.setClipToPadding(false);
// Store the original padding of the RecyclerView. This is crucial
// to preserve any theme-defined padding.
final Rect initialPadding = new Rect(
recyclerView.getPaddingLeft(),
recyclerView.getPaddingTop(),
recyclerView.getPaddingRight(),
recyclerView.getPaddingBottom()
);
// 2. Apply a listener to handle window insets for all orientations
ViewCompat.setOnApplyWindowInsetsListener(recyclerView, (v, insets) -> {
// Get the insets for the system bars (status bar, navigation bar)
Insets theInsets = insets.getInsets(
WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.displayCutout()
);
v.setPadding(
initialPadding.left + theInsets.left,
initialPadding.top + 0,
initialPadding.right + theInsets.right,
initialPadding.bottom + theInsets.bottom
);
// Return the insets to allow the system to continue processing them
return insets;
});
}
}
Мне было интересно, должны ли мы предоставить левый поля для панели инструментов? Если да, как мы должны это сделать?
Подробнее здесь: https://stackoverflow.com/questions/797 ... scape-mode
Мобильная версия