
[英]How to change the title color when using Theme.AppCompat.Light.NoActionBar
[英]AppCompat Theme Error when using NoActionBar
我正在为整个应用程序使用工具栏。 因此,我将应用程序主题设置为Theme.AppCompat.Light.NoActionBar,但是我需要在应用程序的一部分中显示一个警告对话框。 当我尝试显示警报对话框时,出现有关Theme.Appcompat的运行时错误
我的manifest.xml文件
<application
android:allowBackup="true"
android:icon="@drawable/app_icon2"
android:label="@string/app_name"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
>
<activity
android:name="com.project.project.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.project.project.StActivity"
android:configChanges="orientation|screenSize|keyboardHidden"
android:label="@string/app_name">
<intent-filter >
<action android:name="android.intent.action.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
我该怎么办感谢您的帮助
很难看到没有在实际创建Dialog
地方看到代码,但是我猜你是:
Dialog
时不使用Activity
作为Context
。 Activity
上下文包含主题; 如果您尝试使用该Application
则不会获得正确的主题。 Dialog
主题设置为不继承自Theme.AppCompat
(使用构造函数setStyle()
或ContextThemeWrapper
)。 无论哪种方式, Dialog
都不会获取Theme.AppCompat
提供的必需属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.