當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。