[英]No Title Bar theme - The title bar is still appearing
我想要在我的 android 應用程序中“沒有標題欄”。
我已將 AndroidManifest.xml 從 AppTheme.NoActionBar 更改為 Theme.NoTitleBar.Fullscreen 。但標題欄為灰色。 我沒有 Theme.NoTitleBar.Fullscreen 主題的任何樣式。
我還想更改導航菜單圖標顏色。 菜單圖標也沒有改變。
不確定你的意思:
我想要在我的 android 應用程序中“沒有標題欄”。
然后:
我也想更改導航菜單圖標顏色
如果菜單圖標不在標題欄上,應該在哪里顯示?
無論如何,這是一種向后兼容的方法來刪除應用程序中的標題欄:
在您的活動中擴展AppCompatActivity
使用Theme.AppCompat.NoActionBar
作為(應用程序/活動)主題的父主題
在這個主題中,設置這些標志
<item name="windowActionBar">false</item> <item name="windowNoTitle">true</item>
最后,使用android:theme="@style/your_no_title_bar_theme"
將主題應用於AndroidManifest.xml
應用或活動
這里有以下代碼:(如果我問對了你的問題)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { Window w = getWindow(); w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); }
還要看活動的主題
<application
android:name="android.support.multidex.MultiDexApplication"
android:icon="@drawable/logo_icon"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity
android:name=".MainActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
對全屏應用程序使用以下代碼:
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//set content view AFTER ABOVE sequence (to avoid crash)
this.setContentView(R.layout.your_layout_name_here);
並將以下幾行放入樣式文件中:
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
並在清單中將此樣式應用於活動:
<activity
android:theme="@style/AppTheme.NoActionBar">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.