কম্পিউটার টিউটোরিয়াল

Kotlin-এ Android-এ স্ট্যাটাস বার লুকানোর পদ্ধতি

পূর্ব প্রস্তুতি

এই উদাহরণটি দেখায় কিভাবে ফুলস্ক্রিন মোড ব্যবহার করে Android-এ স্ট্যাটাসবার (নোটিফিকেশন বার) লুকানো যায়।

ধাপ ১: নতুন প্রজেক্ট তৈরি করুন

Android Studio-তে File → New Project থেকে প্রজেক্ট শুরু করুন।

ধাপ ২: activity_main.xml লেআউট

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="https://schemas.android.com/apk/res/android"
    xmlns:app="https://schemas.android.com/apk/res-auto"
    xmlns:tools="https://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="70dp"
        android:background="#008080"
        android:padding="5dp"
        android:text="TutorialsPoint"
        android:textColor="#fff"
        android:textSize="24sp"
        android:textStyle="bold" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:text="Hello World!"
        android:textColor="@android:color/holo_blue_dark"
        android:textSize="24sp"
        android:textStyle="bold" />

</RelativeLayout>

ধাপ ৩: MainActivity.kt-এ ফুলস্ক্রিন ফ্ল্যাগ সেট করুন

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Window
import android.view.WindowManager

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // টাইটেলবার লুকান
        requestWindowFeature(Window.FEATURE_NO_TITLE)

        // ফুলস্ক্রিন মোড সক্ষম করুন
        window.setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN
        )

        setContentView(R.layout.activity_main)
        title = "KotlinApp"
    }
}

ধাপ ৪: AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="https://schemas.android.com/apk/res/android"
    package="com.example.statusbarhide">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>

পরীক্ষা করুন

অ্যাপ চালান। স্ট্যাটাসবার (সময়, ব্যাটারি, নোটিফিকেশন আইকন) লুকিয়ে যাবে এবং অ্যাপটি পুরো স্ক্রিন আচ্ছাদন করবে।

আধুনিক বিকল্প (API 30+)

WindowInsetsController API ব্যবহার করে আরও নমনীয়ভাবে সিস্টেমবার নিয়ন্ত্রণ করা যায়।

  1. সুইফটে আইওএস অ্যাপে স্ট্যাটাসবার (Status Bar) লুকানোর পদ্ধতি

  2. অ্যান্ড্রয়েডে একশনবার কীভাবে লুকাবেন?

  3. অ্যান্ড্রয়েডে বর্তমান স্ট্যাটাসবার এলিভেশন (Elevation) কীভাবে পেতে হয়?

  4. অ্যান্ড্রয়েডে স্ট্যাটাস বার কীভাবে লুকাবেন?