關於android中主題的簡介

2021-08-01 03:52:34 字數 2425 閱讀 4022

在進行ui設計時,我們經常需要將螢幕設定成無標題欄或者全屏。要實現起來也非常簡單,主要有兩種方法:配置xml檔案和編寫**設定。

1.在xml檔案中進行配置

在專案的清單檔案androidmanifest.xml中,找到需要全屏或設定成無標題欄的activity,在該activity進行如下配置即可。

實現全屏效果:

android:theme="@android:style/theme.notitlebar.fullscreen"

android:theme="@android:style/theme.notitlebar.fullscreen"
實現無標題欄(但有系統自帶的工作列):

android:theme="@android:style/theme.notitlebar"

android:theme="@android:style/theme.notitlebar"
2.編寫**設定

在程式中編寫**進行設定,只需在oncreate()方法中加入如下**即可

實現全屏效果:

getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,  windowmanager.layoutparams.flag_fullscreen);  

getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,  windowmanager.layoutparams.flag_fullscreen);
實現無標題欄(但有系統自帶的工作列):

requestwindowfeature(window.feature_no_title);  

requestwindowfeature(window.feature_no_title);
附: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.wall*****" 用系統桌面為應用程式背景 

android:theme="theme.wall*****.notitlebar" 用系統桌面為應用程式背景,且無標題欄 

android:theme="theme.wall*****.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" 平板風格顯示

android:theme="@android:style/theme.notitlebar.fullscreen"

android:theme="@android:style/theme.notitlebar"

getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,  windowmanager.layoutparams.flag_fullscreen);

requestwindowfeature(window.feature_no_title);

Android中的主題 Theme

所以同樣是v7相容包,會有api版本號不同的區別,要注意。更多主題 以下都是指 包含 中來看就可以,提示有就有,沒有就沒有。black 黑色風格 light 光明風格 dark 黑暗風格 daynight 白晝風格 wall 牆紙為背景 translucent 透明背景 panel 平板風格 dia...

Android中樣式及主題

最簡單新建乙個android專案都會有乙個textview內容是helloworld 這個時候我們可以將這些屬性寫在 res values styles.xml中新建的樣式中 呼叫 效果如下 自定義theme android allowbackup true android icon drawabl...

Android 的主題的演變

目前比較流行的主題樣式 4.0以後的主題 例如 stylename parent stylename hoho theme material design theme 普及theme和style知識 專案中經常使用style和theme,但卻從來沒有考慮過它們的區別,只會copy來copy去的,有時...