इस लेसन में, लिसनर को रजिस्टर करने का तरीका बताया गया है, ताकि आपके ऐप्लिकेशन को सूचना मिल सके में बदलाव किया जा सकता है. यह तरीका तब काम आता है, जब आपको अपने यूज़र इंटरफ़ेस (यूआई) के अन्य हिस्सों को सिस्टम बार छिपाने/दिखाने के साथ सिंक करें.
लिसनर रजिस्टर करें
सिस्टम यूज़र इंटरफ़ेस (यूआई) के दिखने की सेटिंग में बदलाव की सूचना पाने के लिए,
View.OnSystemUiVisibilityChangeListener
आपके व्यू के लिए.
आम तौर पर, यह ऐसा व्यू होता है जिसका इस्तेमाल नेविगेशन की विज़िबिलिटी को कंट्रोल करने के लिए किया जा रहा है.
उदाहरण के लिए, आप इस कोड को अपनी गतिविधि के
onCreate()
तरीका:
window.decorView.setOnSystemUiVisibilityChangeListener { visibility -> // Note that system bars will only be "visible" if none of the // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set. if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) { // TODO: The system bars are visible. Make any desired // adjustments to your UI, such as showing the action bar or // other navigational controls. } else { // TODO: The system bars are NOT visible. Make any desired // adjustments to your UI, such as hiding the action bar or // other navigational controls. } }
View decorView = getWindow().getDecorView(); decorView.setOnSystemUiVisibilityChangeListener (new View.OnSystemUiVisibilityChangeListener() { @Override public void onSystemUiVisibilityChange(int visibility) { // Note that system bars will only be "visible" if none of the // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set. if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) { // TODO: The system bars are visible. Make any desired // adjustments to your UI, such as showing the action bar or // other navigational controls. } else { // TODO: The system bars are NOT visible. Make any desired // adjustments to your UI, such as hiding the action bar or // other navigational controls. } } });
आम तौर पर, सिस्टम बार में होने वाले बदलावों के साथ अपने यूज़र इंटरफ़ेस (यूआई) को सिंक रखना एक अच्छा तरीका है किसको दिखे. उदाहरण के लिए, इस लिसनर का इस्तेमाल करके, कार्रवाई बार को छिपाया और दिखाया जा सकता है कॉन्सर्ट को दिखाया गया है.