android開發(fā)去除標題欄的方法
1:新建一個項目運行起來,可以看到頂部一直有個標題欄看著不是很美觀

2:有兩種方法可以去除頂部標題欄
(1)將代碼中AndroidManifest里android:theme="@style/Theme.MyApplication"改為android:theme="@style/Theme.AppCompat.NoActionBar">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.NoActionBar"
>
(2)在themes.xml文件里改,選中MyApplication,Ctrl+鼠標點擊

來到themes.xml文件里,把代碼中parent="Theme.MaterialComponents.DayNight.DarkActionBar"替換為
parent=“Theme.AppCompat.Light.NoActionBar”
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
3:效果展示

到此這篇關于android開發(fā)去除標題欄的文章就介紹到這了,更多相關android去除標題欄內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
android中DatePicker和TimePicker的使用方法詳解
這篇文章主要介紹了android中DatePicker和TimePicker的使用方法,是Android中常用的功能,需要的朋友可以參考下2014-07-07
Android ImageButton自定義按鈕的按下效果的代碼實現方法分享
這篇文章主要介紹了Android ImageButton自定義按鈕的按下效果的代碼實現方法,需要的朋友可以參考下2014-02-02
使用androidx BiometricPrompt實現指紋驗證功能
這篇文章主要介紹了使用androidx BiometricPrompt實現指紋驗證功能,對android指紋驗證相關知識感興趣的朋友跟隨小編一起看看吧2021-07-07

