当前位置: 首页>>代码示例>>Java>>正文


Java View.setOnSystemUiVisibilityChangeListener方法代码示例

本文整理汇总了Java中android.view.View.setOnSystemUiVisibilityChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java View.setOnSystemUiVisibilityChangeListener方法的具体用法?Java View.setOnSystemUiVisibilityChangeListener怎么用?Java View.setOnSystemUiVisibilityChangeListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.View的用法示例。


在下文中一共展示了View.setOnSystemUiVisibilityChangeListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hideSystemUI

import android.view.View; //导入方法依赖的package包/类
public static void hideSystemUI(@NonNull final Activity activity, final boolean immediate, final int delayMs) {
    View decorView = activity.getWindow().getDecorView();
    // Set the IMMERSIVE flag.
    // Set the content to appear under the system bars so that the content
    // doesn't resize when the system bars hide and show.
    int uiState = 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
    if (Util.SDK_INT > 18) {
        uiState |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                | View.SYSTEM_UI_FLAG_IMMERSIVE;
    } else {
        final Handler handler = new Handler();
        decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int visibility) {
                if (visibility == View.VISIBLE) {
                    Runnable runnable = new Runnable() {
                        @Override
                        public void run() {
                            hideSystemUI(activity, false);
                        }
                    };
                    if(immediate){
                        handler.post(runnable);
                    }else{
                        handler.postDelayed(runnable, delayMs);
                    }
                }
            }
        });
    }
    decorView.setSystemUiVisibility(uiState);
}
 
开发者ID:Tubitv,项目名称:TubiPlayer,代码行数:37,代码来源:Utils.java

示例2: onCreate

import android.view.View; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    fetchLEDData();
    PowerManager pm = (PowerManager)getSystemService(
            Context.POWER_SERVICE);
    mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK,
            "led");
    mWakeLock.acquire();

    final View decorView = getWindow().getDecorView();
    final int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
            | View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
    decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int i) {
            if ((i & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                mHandler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        decorView.setSystemUiVisibility(uiOptions);
                    }
                },1000);

            } else {
            }
        }
    });
}
 
开发者ID:ZhangQinglian,项目名称:LEDView,代码行数:32,代码来源:LEDActivity.java

示例3: hideDecor

import android.view.View; //导入方法依赖的package包/类
public void hideDecor() {
    if (SettingValues.immersiveMode) {
        final View decorView = getWindow().getDecorView();
        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
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
        decorView.setOnSystemUiVisibilityChangeListener(
                new View.OnSystemUiVisibilityChangeListener() {
                    @Override
                    public void onSystemUiVisibilityChange(int visibility) {
                        if ((visibility) == 0) {
                            decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                                    | View.SYSTEM_UI_FLAG_FULLSCREEN);
                        } else {
                            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
                                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
                        }
                    }
                });
    }
}
 
开发者ID:ccrama,项目名称:Slide-RSS,代码行数:29,代码来源:BaseActivity.java

示例4: lightsOutMode

import android.view.View; //导入方法依赖的package包/类
public void lightsOutMode() {
    lightsOutMode = true;
    final View rootView = getWindow().getDecorView();
    rootView.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
    rootView.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);

    rootView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            MLog.d(TAG, "" + visibility);
            rootView.setSystemUiVisibility(View.STATUS_BAR_VISIBLE);
            rootView.setSystemUiVisibility(View.STATUS_BAR_HIDDEN);
        }
    });
}
 
开发者ID:victordiaz,项目名称:phonk,代码行数:16,代码来源:BaseActivity.java

示例5: enableImmersiveMode

import android.view.View; //导入方法依赖的package包/类
public void enableImmersiveMode(final View decorViewOfActivity) {
    decorViewOfActivity.setSystemUiVisibility(getImmersiveUiVisibility());
    decorViewOfActivity.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
        @Override
        public void onSystemUiVisibilityChange(int visibility) {
            if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
                decorViewOfActivity.setSystemUiVisibility(getImmersiveUiVisibility());
            }
        }
    });
}
 
开发者ID:gsantner,项目名称:memetastic,代码行数:12,代码来源:ContextUtils.java


注:本文中的android.view.View.setOnSystemUiVisibilityChangeListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。