当进入沉浸模式时,我设置 onSystemUiVisibilityChange
在活动中隐藏其他ui元素,但当我从沉浸式模式返回时,它们不会到达其原始位置。
public void controladorInterface(float tempoTouchTotal) {
int delayTouch = 110;
if (tempoTouchTotal <= delayTouch) {
if (isGuiAtivo) {
hideSystemUI();
} else {
showSystemUI();
}
}
decorView.setOnSystemUiVisibilityChangeListener
(new View.OnSystemUiVisibilityChangeListener() {
@Override
public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
imageViewAtivaLegenda.setImageResource(R.drawable.ic_action_olho_off);
imageViewAtivaLegenda.animate().translationY(0).alpha(1).setDuration(0);
switchEsconderNumeroPostes.animate().translationY(0).alpha(1).setDuration(0);
floatingActionMenuMapa.animate().translationY(0).alpha(1).setDuration(0);
cardViewLegenda.animate().translationY(0).alpha(1).setDuration(0);
cardViewLegenda.setVisibility(View.INVISIBLE);
mostraLegenda = true;
isGuiAtivo = true;
} else {
switchEsconderNumeroPostes.animate().translationY(-100f).alpha(0);
cardViewLegenda.animate().translationY(-100f).alpha(0);
imageViewAtivaLegenda.animate().translationY(-100f).alpha(0);
floatingActionMenuMapa.animate().translationY(100f).alpha(0);
isGuiAtivo = false;
}
}
});
}
private void hideSystemUI() {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
private void showSystemUI() {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
暂无答案!
目前还没有任何答案,快来回答吧!