ইমারসিভ মোডের জন্য সিস্টেম বার লুকান

কিছু বিষয়বস্তু স্ট্যাটাস বার বা নেভিগেশন বারে কোনো সূচক ছাড়াই ফুলস্ক্রিনে সবচেয়ে ভালো অভিজ্ঞতা লাভ করে। কিছু উদাহরণ হল ভিডিও, গেমস, ইমেজ গ্যালারী, বই এবং উপস্থাপনা স্লাইড। একে ইমারসিভ মোড বলা হয়। এই পৃষ্ঠাটি দেখায় কিভাবে আপনি পূর্ণস্ক্রীনে বিষয়বস্তুর সাথে ব্যবহারকারীদের আরও গভীরভাবে জড়িত করতে পারেন।

চিত্র 1. ইমারসিভ মোডের উদাহরণ।

ইমারসিভ মোড ব্যবহারকারীদের একটি গেমের সময় দুর্ঘটনাজনিত প্রস্থান এড়াতে সাহায্য করে এবং ছবি, ভিডিও এবং বই উপভোগ করার জন্য একটি নিমগ্ন অভিজ্ঞতা প্রদান করে। যাইহোক, নোটিফিকেশন চেক করতে, অবিলম্বে অনুসন্ধান চালাতে বা অন্যান্য পদক্ষেপ নিতে ব্যবহারকারীরা কত ঘনঘন অ্যাপের ভিতরে এবং বাইরে ঝাঁপিয়ে পড়েন তা মনে রাখবেন। যেহেতু ইমারসিভ মোড ব্যবহারকারীদের সিস্টেম নেভিগেশনের সহজ অ্যাক্সেস হারাতে দেয়, শুধুমাত্র তখনই ইমারসিভ মোড ব্যবহার করুন যখন ব্যবহারকারীর অভিজ্ঞতার সুবিধা কেবলমাত্র অতিরিক্ত স্ক্রীন স্পেস ব্যবহার করার বাইরে যায়৷

সিস্টেম বার লুকানোর জন্য WindowInsetsControllerCompat.hide() এবং সেগুলি ফিরিয়ে আনতে WindowInsetsControllerCompat.show() ব্যবহার করুন।

নিম্নলিখিত স্নিপেটটি সিস্টেম বারগুলিকে লুকানোর এবং দেখানোর জন্য একটি বোতাম কনফিগার করার একটি উদাহরণ দেখায়।

কোটলিন

override fun onCreate(savedInstanceState: Bundle?) {
    ...

    val windowInsetsController =
        WindowCompat.getInsetsController(window, window.decorView)
    // Configure the behavior of the hidden system bars.
    windowInsetsController.systemBarsBehavior =
        WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE

    // Add a listener to update the behavior of the toggle fullscreen button when
    // the system bars are hidden or revealed.
    ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { view, windowInsets ->
        // You can hide the caption bar even when the other system bars are visible.
        // To account for this, explicitly check the visibility of navigationBars()
        // and statusBars() rather than checking the visibility of systemBars().
        if (windowInsets.isVisible(WindowInsetsCompat.Type.navigationBars())
            || windowInsets.isVisible(WindowInsetsCompat.Type.statusBars())) {
            binding.toggleFullscreenButton.setOnClickListener {
                // Hide both the status bar and the navigation bar.
                windowInsetsController.hide(WindowInsetsCompat.Type.systemBars())
            }
        } else {
            binding.toggleFullscreenButton.setOnClickListener {
                // Show both the status bar and the navigation bar.
                windowInsetsController.show(WindowInsetsCompat.Type.systemBars())
            }
        }
        ViewCompat.onApplyWindowInsets(view, windowInsets)
    }
}

জাভা

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

    WindowInsetsControllerCompat windowInsetsController =
            WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView());
    // Configure the behavior of the hidden system bars.
    windowInsetsController.setSystemBarsBehavior(
            WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
    );

    // Add a listener to update the behavior of the toggle fullscreen button when
    // the system bars are hidden or revealed.
    ViewCompat.setOnApplyWindowInsetsListener(
        getWindow().getDecorView(),
        (view, windowInsets) -> {
        // You can hide the caption bar even when the other system bars are visible.
        // To account for this, explicitly check the visibility of navigationBars()
        // and statusBars() rather than checking the visibility of systemBars().
        if (windowInsets.isVisible(WindowInsetsCompat.Type.navigationBars())
                || windowInsets.isVisible(WindowInsetsCompat.Type.statusBars())) {
            binding.toggleFullscreenButton.setOnClickListener(v -> {
                // Hide both the status bar and the navigation bar.
                windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());
            });
        } else {
            binding.toggleFullscreenButton.setOnClickListener(v -> {
                // Show both the status bar and the navigation bar.
                windowInsetsController.show(WindowInsetsCompat.Type.systemBars());
            });
        }
        return ViewCompat.onApplyWindowInsets(view, windowInsets);
    });
}

ঐচ্ছিকভাবে, কোনো ব্যবহারকারীর সাথে ইন্টারঅ্যাক্ট করার সময় আপনি সিস্টেম বারের ধরন লুকিয়ে রাখতে এবং তাদের আচরণ নির্ধারণ করতে পারেন।

কোন সিস্টেম বার লুকাতে হবে তা নির্দিষ্ট করুন

লুকানোর জন্য সিস্টেম বারগুলির ধরন নির্দিষ্ট করতে, নিম্নলিখিত প্যারামিটারগুলির মধ্যে একটিকে WindowInsetsControllerCompat.hide() এ পাস করুন।

লুকানো সিস্টেম বারের আচরণ নির্দিষ্ট করুন

ব্যবহারকারী যখন তাদের সাথে ইন্টারঅ্যাক্ট করে তখন লুকানো সিস্টেম বারগুলি কীভাবে আচরণ করে তা নির্দিষ্ট করতে WindowInsetsControllerCompat.setSystemBarsBehavior() ব্যবহার করুন।

  • সংশ্লিষ্ট ডিসপ্লেতে ব্যবহারকারীর কোনো ইন্টারঅ্যাকশনে লুকানো সিস্টেম বার প্রকাশ করতে WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_TOUCH ব্যবহার করুন।

  • WindowInsetsControllerCompat.BEHAVIOR_SHOW_BARS_BY_SWIPE ব্যবহার করুন যেকোন সিস্টেম অঙ্গভঙ্গিতে লুকানো সিস্টেম বার প্রকাশ করতে, যেমন স্ক্রিনের প্রান্ত থেকে সোয়াইপ করা যেখানে বারটি লুকানো আছে।

  • WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE ব্যবহার করুন অস্থায়ীভাবে সিস্টেম অঙ্গভঙ্গি সহ লুকানো সিস্টেম বারগুলি প্রকাশ করতে, যেমন স্ক্রিনের প্রান্ত থেকে সোয়াইপ করা যেখানে বারটি লুকানো আছে৷ এই ক্ষণস্থায়ী সিস্টেম বারগুলি আপনার অ্যাপের বিষয়বস্তুকে ওভারলে করে, কিছুটা স্বচ্ছতা থাকতে পারে এবং অল্প সময়ের পরে স্বয়ংক্রিয়ভাবে লুকানো হয়৷