在使用android:theme="@android:style/Theme.NoTitleBar"时出现错误:You need to use a Theme.AppCompat theme (or descendant) with this activity.
``解决方法:
设置
actionBar.setDisplayShowCustomEnabled(true)或者actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); //Enable自定义的View
或者
在AndroidManifest.xml中将主题更改为Theme.AppCompat.Light.NoActionBar、Theme.AppCompat.NoActionBar或Theme.AppCompat.DayNight.NoActionBar中的一个,即可隐藏标题栏
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"//成功隐藏标题栏
>
或者在style.xml里面添加
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">true</item>
本文详细介绍了在Android开发中,使用Theme.NoTitleBar时遇到的错误“You need to use a Theme.AppCompat theme (or descendant) with this activity.”的解决办法。提供了通过修改AndroidManifest.xml中的主题或使用AppCompat主题来成功隐藏标题栏的方法。
1万+

被折叠的 条评论
为什么被折叠?



