Android Studio實(shí)現(xiàn)標(biāo)題欄和狀態(tài)欄的隱藏和eclipse有很大不同,其實(shí)隨著Android界面越來越美觀,效果也越來越生動(dòng),下面武林技術(shù)頻道小編就來簡(jiǎn)單介紹Android Studio實(shí)現(xiàn)標(biāo)題欄和狀態(tài)欄隱藏的實(shí)例演示。
在Eclipse上隱藏標(biāo)題欄和狀態(tài)欄的代碼如下:
方法一: requestWindowFeature(Window.FEATURE_NO_TITLE);
方法二:getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
今天在做閃屏頁(yè)開發(fā)時(shí),想把標(biāo)題欄和狀態(tài)欄隱藏掉,但這兩種方法嘗試后都不行。
最后的解決方案:
①先在values的styles.xml中添加子標(biāo)簽:
<style name="NoTitle" parent="Theme.AppCompat.DayNight.NoActionBar"> <item name="android:windowNoTitle">true</item> <item name="android:windowFullscreen">true</item> </style>
②在清單文件中,需要隱藏標(biāo)題欄和狀態(tài)欄的Activity引用此樣式:
<activity android:name=".SplashActivity" android:theme="@style/NoTitle">
經(jīng)過這兩步,便是一個(gè)沒有標(biāo)題欄和狀態(tài)欄的完美閃屏頁(yè)了!
PS:下面看下Android Studio 去掉標(biāo)題欄狀態(tài)欄的完整代碼
**網(wǎng)上關(guān)于Android Studio的教程比較少,去掉標(biāo)題欄的方法大多不能直接使用。
在Android Studio中其實(shí)更簡(jiǎn)單一些,在app/res/values/styles.xml文件中加個(gè)標(biāo)簽就可以了**
<item name="windowNoTitle">true</item>
完整代碼如下,可以看到這段代碼放在什么位置。
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="windowNoTitle">true</item> </style> </resources>
加到 加載視圖前面
//取消狀態(tài)欄 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
上面是武林技術(shù)頻道小編介紹的Android Studio實(shí)現(xiàn)標(biāo)題欄和狀態(tài)欄隱藏的實(shí)例演示,希望對(duì)你有所幫助。如有任何疑問,請(qǐng)留言給小編,非常感謝您對(duì)武林技術(shù)頻道的支持。
新聞熱點(diǎn)
疑難解答
圖片精選