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

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

ছবি ১. ইমারসিভ মোডের উদাহরণ।

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

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

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

Kotlin

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 ব্যবহার করুন, যেমন স্ক্রিনের যে প্রান্তে বারটি লুকানো আছে সেখান থেকে সোয়াইপ করা। এইসব ট্রানজিয়েন্ট সিস্টেম বার আপনার অ্যাপের কন্টেন্ট ওভারলে করে, কিছুটা স্বচ্ছ হতে পারে এবং অল্প সময়ের পরে অটোমেটিক লুকিয়ে যায়।