API 35-Обработайте край до края в предпочтенииAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 API 35-Обработайте край до края в предпочтении

Сообщение Anonymous »

Я работаю над краем до края, API 35, для материала 2, Java Android Project.

Код: Выделить всё

AppBarLayout
= android: fitssystemwindows = "true"
[*]

Код: Выделить всё

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
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»