简体   繁体   English

如何在Android活动中禁用工具栏?

[英]How to disable Toolbar in android activity?

I'm trying disable the toolbar in my Login Activity. 我正在尝试在登录活动中禁用工具栏。 I have tried all the methods i could find so far. 到目前为止,我已经尝试了所有可以找到的方法。

<application
    android:name="app.AppController"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

activity
        android:name=".LoginActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

here is my styles xml file 这是我的样式xml文件

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="AppTheme.NoActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

I have even tried to remove it programatically with 我什至尝试以编程方式将其删除

this.requestWindowFeature(Window.FEATURE_NO_TITLE);

also removed these lines of codes. 还删除了这些代码行。

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

still no luck. 仍然没有运气。 I dont see the toolbar in my design preview in android studio. 我在Android Studio的设计预览中看不到工具栏。 But when i run the app using the emulator it shows the toolbar. 但是,当我使用模拟器运行该应用程序时,它将显示工具栏。 I'm emulating it on a Nexus 4 with the api 22. 我正在使用api 22在Nexus 4上进行仿真。

Have i missed anything or done something wrong? 我错过了什么或做错了什么吗? Can anyone point me in the right direction. 谁能指出我正确的方向。

I have forgotten to remove the toolbar from the activity xml. 我忘了从活动xml中删除工具栏。 I had only removed the toolbar from the content xml file. 我只从内容xml文件中删除了工具栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM