雖然是一個小問題,今天遇到了,也就寫下來吧。防止自己忘掉。
取消標題欄的方式有兩種,一種是在代碼添加,另一種是在AndroidManifest.xml里面添加。
1、在代碼中實現:
在此方法setContentView(R.layout.main)之前加入:
requestWindowFeature(Window.FEATURE_NO_TITLE);標題欄就沒有了。
2、在AndroidManifest.xml中實現:
注冊Activity時加上如下的一句配置就可以實現。
<activity android:name=".Activity"
android:theme="@android:style/Theme.NoTitleBar"
>
</activity>
附:Android系統自帶樣式
android:theme="@android:style/Theme.Dialog" 將一個Activity顯示為能話框模式
android:theme="@android:style/Theme.NoTitleBar" 不顯示應用程序標題欄
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 不顯示應用程序標題欄,並全屏
android:theme="Theme.Light" 背景為白色
android:theme="Theme.Light.NoTitleBar" 白色背景並無標題欄
android:theme="Theme.Light.NoTitleBar.Fullscreen" 白色背景,無標題欄,全屏
android:theme="Theme.Black" 背景黑色
android:theme="Theme.Black.NoTitleBar" 黑色背景並無標題欄
android:theme="Theme.Black.NoTitleBar.Fullscreen" 黑色背景,無標題欄,全屏
android:theme="Theme.Wallpaper" 用系統桌面為應用程序背景
android:theme="Theme.Wallpaper.NoTitleBar" 用系統桌面為應用程序背景,且無標題欄
android:theme="Theme.Wallpaper.NoTitleBar.Fullscreen" 用系統桌面為應用程序背景,無標題欄,全屏
android:theme="Translucent" 透明背景
android:theme="Theme.Translucent.NoTitleBar" 透明背景並無標題
android:theme="Theme.Translucent.NoTitleBar.Fullscreen" 透明背景並無標題,全屏
android:theme="Theme.Panel" 面板風格顯示
android:theme="Theme.Light.Panel" 平板風格顯示