android – 如何禁用导航栏幻灯片动画进入全屏?

我有一个活动进入另一个全屏幕活动.但是,当从此活动转换到全屏幕活动时,导航栏会向下滑动而不是立即消失.在第二个活动中,我已经充满了一个全屏幕窗口,但是由于滑动动画慢,所以动画完成后1秒钟会重新调整大小,而不是立即充满全屏幕.因此,我需要动画立即消失.我试过了

< item name =“Android:windowAnimationStyle”> @ null< / item>

overridePendingTransition(0, 0);

Transition fade = new Fade();
fade.excludeTarget(android.R.id.navigationBarBackground, true);
getWindow().setEnterTransition(fade);

没有运气.

在Windows端,我试过了

WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS 
WindowManager.LayoutParams.FLAG_FULLSCREEN 
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN

如何隐藏导航栏:View.SYSTEM_UI_FLAG_HIDE_NAVIGATION

我想,我钉住它:

enter image description here

FullscreenActivity类:

public class FullscreenActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
        decorView.setSystemUiVisibility(uiOptions);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }

        setContentView(R.layout.activity_fullscreen);
    }
}

表现:

    <activity
        android:name=".FullscreenActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/title_activity_fullscreen"
        android:theme="@style/FullscreenTheme"/>

样式:

<style name="FullscreenTheme" parent="AppTheme">
    <item name="android:statusBarColor">@android:color/transparent</item>
    <item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
    <item name="android:windowActionBarOverlay">true</item>
    <item name="android:windowBackground">@null</item>
    <item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
    <item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>

NB!设置StatusBar颜色需要API 21.对于旧版本,要“隐藏”StatusBar,您需要使用:

        int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN;

作为uiOptions在上面的代码. (它会导致相当快的调整大小,但是).

我希望它有帮助

翻译自:https://stackoverflow.com/questions/34976783/how-to-disable-the-navigation-bar-slide-animation-when-going-fullscreen

转载注明原文:android – 如何禁用导航栏幻灯片动画进入全屏?