我是android,Kotlin的初学者,我不知道如何在特定的所有活动中删除顶部的应用栏。我有一个初始屏幕和一个新活动,以下是我样式的代码,我已经在styles.xml中导入了材质设计,我不知道删除styles.xml中顶部应用栏的方法是什么
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
</resources>
Android清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.shanjostech.newsample">
<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=".Main_Screen"></activity>
<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>
这个问题已经在这里回答:
如何从所有活动中将其删除
如何将其从特定活动中删除
如果它们都不适合您,请尝试以下操作:
对于特定活动,
在清单文件中设置主题,如下所述:
<activity android:name=".activity.ContinueLoginActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:screenOrientation="portrait" />
以编程方式:-
科特林:
supportActionBar?.hide()
Java:
if (getSupportActionBar() != null) {
getSupportActionBar().hide();
}
要从所有活动中将其删除,请在style.xml文件中将.DarkActionBar更改为.NoActionBar:
<resources>
<!-- Base application theme. -->
<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>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句