Android 覆盖活动';由主题设置的背景
我目前有一个启动屏幕的活动。以下是我将主题应用于活动的方式:Android 覆盖活动';由主题设置的背景,android,android-activity,android-alertdialog,android-theme,android-styles,Android,Android Activity,Android Alertdialog,Android Theme,Android Styles,我目前有一个启动屏幕的活动。以下是我将主题应用于活动的方式: <application ... <activity android:name=".activities.SplashActivity" android:configChanges="orientation|keyboardHidden" android:screenOrientation="portrait" android:theme="
<application
...
<activity
android:name=".activities.SplashActivity"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
一旦应用活动主题,就不可能更改它
是否有一种方法可以覆盖主题定义的android:background
,用于警报对话框
AlertDialog
有一个构造函数,它接受themeResId
作为输入。发件人:
创建使用显式主题资源的警报对话框
创建自定义主题,覆盖android:background
属性,然后使用新创建的主题创建AlertDialog
:
Dialog dialog = new AlertDialog(context, R.style.my_dialog_theme);
一旦应用活动主题,就不可能对其进行更改
是否有一种方法可以覆盖主题定义的android:background
,用于警报对话框
AlertDialog
有一个构造函数,它接受themeResId
作为输入。发件人:
创建使用显式主题资源的警报对话框
创建自定义主题,覆盖android:background
属性,然后使用新创建的主题创建AlertDialog
:
Dialog dialog = new AlertDialog(context, R.style.my_dialog_theme);
<style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash_background</item>
</style>
Dialog dialog = new AlertDialog(context, R.style.my_dialog_theme);