UI দৃশ্যমানতার পরিবর্তনে সাড়া দিন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
এই পাঠটি বর্ণনা করে কিভাবে একজন শ্রোতাকে নিবন্ধন করতে হয় যাতে আপনার অ্যাপটি সিস্টেম UI দৃশ্যমানতার পরিবর্তন সম্পর্কে বিজ্ঞপ্তি পেতে পারে। আপনি যদি সিস্টেম বারগুলি লুকিয়ে/দেখানোর সাথে আপনার UI এর অন্যান্য অংশগুলিকে সিঙ্ক্রোনাইজ করতে চান তবে এটি কার্যকর।
একজন শ্রোতা নিবন্ধন করুন
সিস্টেম UI দৃশ্যমানতার পরিবর্তন সম্পর্কে বিজ্ঞপ্তি পেতে, আপনার ভিউতে একটি 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.
}
}
});
সিস্টেম বার দৃশ্যমানতার পরিবর্তনের সাথে আপনার UI কে সিঙ্কে রাখা সাধারণত ভাল অভ্যাস। উদাহরণস্বরূপ, আপনি স্ট্যাটাস বার লুকানো এবং দেখানোর সাথে অ্যাকশন বারটি লুকিয়ে রাখতে এবং দেখানোর জন্য এই শ্রোতাকে ব্যবহার করতে পারেন।
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-29 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-07-29 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# Respond to UI visibility changes\n\nThis lesson describes how to register a listener so that your app can get notified\nof system UI visibility changes. This is useful if you want to\nsynchronize other parts of your UI with the hiding/showing of system bars.\n\nRegister a Listener\n-------------------\n\nTo get notified of system UI visibility changes, register an\n[View.OnSystemUiVisibilityChangeListener](/reference/android/view/View.OnSystemUiVisibilityChangeListener) to your view.\nThis is typically the view you are using to control the navigation visibility.\n\nFor example, you could add this code to your activity's\n[onCreate()](/reference/android/app/Activity#onCreate(android.os.Bundle)) method: \n\n### Kotlin\n\n```kotlin\nwindow.decorView.setOnSystemUiVisibilityChangeListener { visibility -\u003e\n // Note that system bars will only be \"visible\" if none of the\n // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.\n if (visibility and View.SYSTEM_UI_FLAG_FULLSCREEN == 0) {\n // TODO: The system bars are visible. Make any desired\n // adjustments to your UI, such as showing the action bar or\n // other navigational controls.\n } else {\n // TODO: The system bars are NOT visible. Make any desired\n // adjustments to your UI, such as hiding the action bar or\n // other navigational controls.\n }\n}\n```\n\n### Java\n\n```java\nView decorView = getWindow().getDecorView();\ndecorView.setOnSystemUiVisibilityChangeListener\n (new View.OnSystemUiVisibilityChangeListener() {\n @Override\n public void onSystemUiVisibilityChange(int visibility) {\n // Note that system bars will only be \"visible\" if none of the\n // LOW_PROFILE, HIDE_NAVIGATION, or FULLSCREEN flags are set.\n if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {\n // TODO: The system bars are visible. Make any desired\n // adjustments to your UI, such as showing the action bar or\n // other navigational controls.\n } else {\n // TODO: The system bars are NOT visible. Make any desired\n // adjustments to your UI, such as hiding the action bar or\n // other navigational controls.\n }\n }\n});\n```\n\nIt's generally good practice to keep your UI in sync with changes in system bar\nvisibility. For example, you could use this listener to hide and show the action bar in\nconcert with the status bar hiding and showing."]]