I'm trying to hide the Toolbar so I can put my own one in but the toolbar still shows, could someone help please. The theme @style/AppTheme.NoActionBar
works in other activities.
Manifest:
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan"/>
Style:
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Activity:
class MainActivity : AppCompatActivity() {
private val fireStoreInstance: FirebaseFirestore by lazy { FirebaseFirestore.getInstance() }
private val currentUserDocRef: DocumentReference
get() = fireStoreInstance.document("users/${FirebaseAuth.getInstance().currentUser?.uid
?: throw NullPointerException("UID is null.")}")
internal lateinit var helper: RealmHelper
internal lateinit var realm: Realm
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Realm.init(applicationContext)
val defaultConfig = RealmConfiguration.Builder()
.schemaVersion(0)
.build()
realm = Realm.getInstance(defaultConfig)
helper = RealmHelper(realm)
fireStoreInstance.collection("users").document(FirebaseAuth.getInstance()
.currentUser?.uid.toString()).get().addOnCompleteListener { task ->
if (task.isSuccessful) {
AppConstants.USER_ROLE = task.result["role"].toString()
}
}
val list = helper.retrieveAT()
if (list.count() <= 0) {
fireStoreInstance.collection("assessmentType").get().addOnCompleteListener(OnCompleteListener<QuerySnapshot> { task ->
if (task.isSuccessful) {
val list = ArrayList<AssessmentType>()
for (document in task.result) {
val u = AssessmentType(document.id,document.get("Desc")!!.toString())
helper.save(u)
}
}
})
}
this.replaceFragment(PeopleFragment())
navigation.setOnNavigationItemSelectedListener {
when (it.itemId) {
R.id.navigation_chat -> {
this.replaceFragment(PeopleFragment())
true
}
R.id.navigation_modules -> {
this.replaceFragment(ModuleFragment())
true
}
R.id.navigation_timetable -> {
this.replaceFragment(TimetableFragment())
true
}
R.id.navigation_profile -> {
this.replaceFragment(MyAccountFragment())
true
}
else -> false
}
}
}
@SuppressLint("CommitTransaction")
private fun replaceFragment(fragment: Fragment) {
supportFragmentManager.beginTransaction()
.replace(R.id.fragment_layout, fragment)
.commit()
}
}
Screen:
This works for me in every app...
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>