[英]How to disable Toolbar in android activity?
我正在嘗試在登錄活動中禁用工具欄。 到目前為止,我已經嘗試了所有可以找到的方法。
<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>
這是我的樣式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" />
我什至嘗試以編程方式將其刪除
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
還刪除了這些代碼行。
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
仍然沒有運氣。 我在Android Studio的設計預覽中看不到工具欄。 但是,當我使用模擬器運行該應用程序時,它將顯示工具欄。 我正在使用api 22在Nexus 4上進行仿真。
我錯過了什么或做錯了什么嗎? 誰能指出我正確的方向。
我忘了從活動xml中刪除工具欄。 我只從內容xml文件中刪除了工具欄。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.