我正试图隐藏工具栏,以便可以放入自己的工具栏,但工具栏仍显示,请有人帮忙。主题@style/AppTheme.NoActionBar
在其他活动中也起作用。
清单:
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan"/>
样式:
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
活动:
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()
}
}
屏幕:
答案 0 :(得分:1)
您可以使用下面的代码隐藏操作栏
getActivity().getSupportActionBar().hide();
答案 1 :(得分:1)
您的主题不完整,就像
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
上述parent="Theme.AppCompat.Light.NoActionBar"
样式是解决问题所需要的。
所以您的风格必须是
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
</style>
答案 2 :(得分:1)
这对我每个应用程序都适用...
& "${env:PYTHON2PATH}\python.exe"