I'm using Android Studio Giraffe | 2022.3.1 and I can't properly hide the ActionBar.
I saw both this and this related questions but they didn't help me.
Here is my MainActivity.kt file:
package com.example.motivation
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import com.example.motivation.databinding.ActivityMainBinding
class MainActivity : AppCompatActivity(), View.OnClickListener {
private lateinit var binding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
// Hide ActionBar
supportActionBar?.hide()
// Events
binding.buttonNewPhrase.setOnClickListener(this)
}
override fun onClick(view: View) {
if (view.id == R.id.button_new_phrase){
}
}
}
Also in the themes.xml there is no ActionBar by default, haven't change it
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Base.Theme.Motivation" parent="Theme.Material3.DayNight.NoActionBar">
<!-- Customize your light theme here. -->
<!-- <item name="colorPrimary">@color/my_light_primary</item> -->
</style>
<style name="Theme.Motivation" parent="Base.Theme.Motivation" />
</resources>
And here is the AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Motivation"
tools:targetApi="31">
<activity
android:name=".UserActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>
</manifest>
When I execute the app, the ActionBar is still there:
Why I can't hide it at all?

1.First way to hide ActionBar :
Second way to Hide Action Bar for a particular activity:
3.Third way is that Add this code in kotlin file